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.

49 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

22. wrote:
quanto costa il tadalafil [url=]cialis online[/url] prix tadalafil 10mg cialis prescription tadalafil achat ligne tadalafil articles donde comprar tadalafil generico

Thu, October 24, 2019 @ 12:14 AM

23. wrote:
Tarot reading Tarot card reading

Thu, October 24, 2019 @ 9:54 AM

24. wrote:
para que se toma el tadalafil [url=]buy
cialis online[/url] qual a diferença entre levitra e tadalafil buy
cialis online viagra or tadalafil bodybuilding

Wed, October 30, 2019 @ 3:33 AM

25. wrote: The Bengali
film industry has become there since 1890sed a
whole lot and thus gets the quantity of film lovers. As the latest member of Toy Story series, the movie tells the tale of how Woody leads
his squad to acquire free from day-care center to
obtain back to Andy. Cable operating companies also
give such a case to deliver their clients using services.

Tue, November 5, 2019 @ 9:56 AM

26. wrote:

Sun, November 10, 2019 @ 6:03 PM

27. wrote:

Thu, November 14, 2019 @ 5:40 PM

28. wrote:
que es magnus sildenafil [url=]buy viagra online[/url] sildenafil liquid form viagra for women buy sildenafil
50mg tablets sildenafil 100mg how long does it take
to work unterschied
sildenafil vardenafil

Fri, November 22, 2019 @ 7:13 PM

29. wrote:
tadalafil patente [url=]cialis pills[/url] tadalafil recommended dosage buy cialis online tadalafil
cas number tadalafil to treat high blood pressure harga cialis 20mg tadalafil

Sat, November 23, 2019 @ 2:31 AM

30. wrote:

Sat, November 30, 2019 @ 11:30 AM

31. wrote:

Sat, November 30, 2019 @ 1:26 PM

32. wrote:
I visit each day some sites and information sites to read content, but this web
site gives quality based posts.

Wed, December 4, 2019 @ 10:40 PM

33. wrote:
anywhere tadalafil e ciclismo [url=]generic viagra
100mg for sale[/url] strongly differenza tra tadalafil ® e tadalafil frequently
preço do tadalafil de 5mg order viagra tablets from canada false compare prices tadalafil uk roughly tadalafil dose 40 mg any
what happens if you take too much tadalafil

Thu, December 5, 2019 @ 12:29 PM

34. wrote:
cialis otc
[url=]cialis otc[/url]

Thu, December 19, 2019 @ 5:11 PM

35. wrote:

Sat, December 28, 2019 @ 11:06 AM

36. wrote:
Spot on with this write-up, I seriously believe this site needs a great deal more attention. I'll probably be returning to read more, thanks for the information!

Sat, December 28, 2019 @ 7:15 PM

37. wrote:

Mon, January 6, 2020 @ 2:24 PM

38. wrote:

Mon, January 13, 2020 @ 4:49 PM

39. wrote:
fully nature bimatoprost fast bathroom previously desire buy naltrexone
online previously birthday short sense careprost buy online basically grade [url=]careprost 3ml eye
drops[/url] likely farm naltrexone weight loss somewhat cable

Sat, January 18, 2020 @ 7:26 AM

40. wrote:
For most recent news you have to pay a quick visit world-wide-web
and on internet I found this web site as a best web site for most
up-to-date updates.

Fri, January 24, 2020 @ 5:39 PM

41. wrote:
Using the Loader class in AS3 | Sean Dooley

Sat, January 25, 2020 @ 11:44 PM

42. wrote:
attach [url=]generic viagra release date[/url] buy viagra viagra sales float

Thu, January 30, 2020 @ 12:18 AM

43. wrote:
defend [url=]no perscription generic viagra[/url] generic viagra online pharmacy review fast delivery generic viagra holy

Sun, February 2, 2020 @ 12:09 PM

44. wrote:

Sun, February 9, 2020 @ 12:17 PM

45. wrote:

Tue, February 11, 2020 @ 3:16 PM

46. wrote:
Hello there I am so thrilled I found your blog page, I really found you by accident,
while I was searching on Bing for something else, Anyways
I am here now and would just like to say cheers for a incredible
post and a all round interesting blog (I also love the theme/design), I don’t have time to read through it all at the minute but I have
bookmarked it and also included your RSS feeds, so when I have time I will be back to
read more, Please do keep up the fantastic b.

Thu, February 13, 2020 @ 2:46 PM

47. wrote:
I must thank you for the efforts you've put in writing this website.

I really hope to check out the same high-grade content by you later on as well.
In fact, your creative writing abilities has motivated me to get my very own blog now

Thu, February 13, 2020 @ 11:52 PM

48. wrote:

Fri, February 14, 2020 @ 7:01 PM

49. wrote:

Mon, February 17, 2020 @ 12:34 PM

Add a New Comment


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