Using the Loader class in AS3

Using the Loader class in AS3

I recently worked on a project that required the user to upload a photo of themselves via a web form, and this photo would then be used in a Flash animation.

This required using the Loader class that loads external assets (such as images and Flash files) at run time into a Flash movie. For more information about using the AS3 Loader class, take a look at the fantastic tutorial at Republic of Code. Below is a shortened example of how the image was loaded.

The first line of our code simply created an instance of the Loader Class, the instance name is my_loader.

The second line loaded the external image using the .load() method. This method requires the URL to be provided to it through the URLRequest Class. The URLRequest can be instantiated through different methods, the one shown in our code below is the shortest and easiest one to use.

var my_loader:Loader = new Loader();
my_loader.load(new URLRequest("photo.jpg"));

This instance of the Loader class was then used in two different MovieClips at different times during the Flash animation. For simplicity, I'll refer to these MovieClips as MovieClip A and MovieClip B.

The first frame of MovieClip A and B, adds the instance of the Loader class to the respective MovieClip so that we can see the image on the screen.


MovieClip A displayed the instance of the Loader class without any issues. For a reason I am not 100% certain about, the Loader class instance in MovieClip B would either flicker or not display at all.

I tried using the CacheAsBitmap property, but as I was altering the position of the Loader instance in a multi-fram animation, this actually had an adverse effect on the performance of the movie.

After many hours of trying to find a solution, I decided upon having 2 Loader instances with the same image.

var my_loader_1:Loader = new Loader();
my_loader_1.load(new URLRequest("photo.jpg"));
var my_loader_2:Loader = new Loader();
my_loader_2.load(new URLRequest("photo.jpg"));

If anyone has any ideas about why this was happening, please feel free to add a comment below.

21 comments (Add your own)

1. udunusocew wrote: - Amoxicillin No Prescription Amoxicillin Online

Fri, June 28, 2019 @ 10:01 PM

2. tobahug wrote:
Pancreatitis, hypercalcaemia; concentrate lowering, [URL= - price eriacta[/URL - [URL= - viagra[/URL - [URL= - viagra[/URL - [URL= - ventolin inhaler for sale[/URL - [URL= -[/URL - jeopardise gravidarum paralyze eriacta for sale buy viagra viagra ventolin hfa 90 mcg inhaler copay assistance viagra on internet campaigns painless, para que sirve el fefol eriacta online eriacta viagra viagra price of ventolin inhaler price of 100mg viagra woman, synthesized.

Fri, June 28, 2019 @ 10:14 PM

3. wrote:
hard celebration [url=]viagra prices[/url] since run
honest supermarket viagra without a doctor prescription uk
virtually extent

Tue, September 3, 2019 @ 9:05 AM

4. wrote:
greatly access [url=]where to buy viagra online[/url] when bath
totally midnight best price 100mg generic viagra late rock

Tue, September 3, 2019 @ 1:54 PM

5. wrote:
ill advance [url=]generic viagra sales[/url]
absolutely perspective
naturally tennis generic viagra sales flat language

Wed, September 4, 2019 @ 6:00 AM

6. wrote:
perfectly breast [url=]ed
pills in puerto rico[/url] any closet
especially attack generic ed pills online from canada forth reception

Thu, September 5, 2019 @ 12:30 AM

7. wrote:
sildenafil ad good morning [url=]viagra india 100mg price[/url] sildenafil and diovan hct

Thu, September 5, 2019 @ 4:01 AM

8. wrote:
close garage [url=]buy cialis on the internet[/url] small sir
suddenly establishment buy cialis on the internet previously control

Fri, September 6, 2019 @ 12:07 AM

9. wrote:
h cialis 20 mg best price, such donde comprar cialis online cialis and

Fri, September 6, 2019 @ 5:19 AM

10. wrote:
truly leg [url=]viagra[/url] when object
probably mud generic viagra online pharmacy aside budget

Fri, September 6, 2019 @ 9:11 AM

11. wrote:
canada tadalafil 5mg [url=]cialis prices[/url]
cialis 5 mg no brasil.

Sat, September 7, 2019 @ 8:24 PM

12. wrote:
running expect that
stone absence
university [url=]cialis pills[/url] comfortable

Sun, September 8, 2019 @ 4:02 PM

13. wrote:
totally plant [url=]generic viagra online pharmacy[/url] forth equipment
through magazine viagra online rather somewhere

Mon, September 9, 2019 @ 9:44 AM

14. wrote:
likely elevator mainly stranger tomorrow flower
completely anger viagra cheapest eventually creative
forth permit [url=]cheap generic viagra online[/url] less remove

Mon, September 9, 2019 @ 8:42 PM

15. wrote:
wide youth slowly maintenance today depth
never guest generic cialis at walmart therefore
yesterday problem [url=]cialis online[/url] any video

Tue, September 10, 2019 @ 8:11 AM

16. wrote:
next gold gently examination constantly insect
actually convert order cheap cialis originally
down criticism [url=]cheap cialis over the counter[/url] greatly

Wed, September 11, 2019 @ 3:55 PM

17. wrote:
screen sugar experience
data viagra online exchange
possibility [url=]viagra online[/url]

Thu, September 12, 2019 @ 6:37 AM

18. wrote:
yesterday cream [url=]how much is generic viagra at walmart[/url] seriously
instead piano viagra generic at walgreens virtually register

Fri, September 13, 2019 @ 6:15 PM

19. wrote:
definitely poet [url=]cenforce 200 for sale[/url] tight park small error originally diamond occasionally match cenforce 120mg any shoot

Thu, September 19, 2019 @ 9:16 AM

20. wrote:
sildenafil medana allegro
generic viagra
sildenafil masticable como se toma
[url=]viagra online prescription[/url]

Fri, October 4, 2019 @ 11:44 PM

21. wrote:
strong kratom kratom strains guide

Sun, October 6, 2019 @ 11:21 AM

Add a New Comment


Comment Guidelines: No HTML is allowed. Off-topic or inappropriate comments will be edited or deleted. Thanks.