Skip to main content
Inspiring
March 20, 2009
Answered

How do I preload an external swf file into my main timeline?

  • March 20, 2009
  • 4 replies
  • 876 views
In trying to keep file size down for download time... I have a SWF file that I have placed using the "UILoader" component (not sure if this is the correct thing to do)... what I would like to work out is how to make a preloader within my main timeline for this SWF file when it comes in...

I hope that makes sense - I am very new to all this and struggling with terminology etc.

I figured Actionscript would be what I need - but no clue right now...
This topic has been closed for replies.
Correct answer Bimibear
I now know how to get the external files to load - but after some investigation I have realised I need to unload the file when a mouse event occurs... does anyone know how I can achieve this - I have googled all day but haven't been successful in finding the solution - have reached ripping out the hair stage!

Any help would be greatly appreciated.
Many thanks.

I am finishing off this thread for people that are looking for a way to preload external SWF files. Please note however that I have started a new thread about unloading the file again on a mouse event... so although this is not completely final it will start the process of preloading an external SWF... Hope it helps someone.

4 replies

Ned Murphy
Legend
March 21, 2009
For the code you showed to preload the swf, you should assign the event listeners before the command to load... not so much a necessity, just a better practice.

You now seem to want to get rid of the swf once it has loaded and played itself thru. To do that you would need to have something in the swf itself that triggers its removal in its last frame. The following might work...

MovieClip(this.parent).removeChild(this);
BimibearAuthor
Inspiring
March 22, 2009
Hi NedWebs,

Thanks for that - I will give it a try.
Do you how I would be able to get the SWF to loop UNLESS another button on the main SWF has been clicked or rollover?
Many thanks.
BimibearAuthor
Inspiring
March 21, 2009
Hi combustion007,
Thanks for the offer - my file is at work - so wont be back until Monday... if you wouldn't mind looking at it then that would be fantastic. Not sure how to show the entire code though... that's the only code I have put on that frame... what else do I need to put up for you to see?

Thanks again.
March 20, 2009
Hey Bimibear,

show your entire code, so I can then see what is going on. You need to get debugging going. The above code looks good to me, but how about just simply load the swf file locally and see it goes well without the preloader.

Thanks.
March 20, 2009
Bimibear,

Well, you just gotta be patient with Actionscript. You do need to employ a pre-loader which will load your content on runtime. Try this tutorial, this will do the trick:

http://www.actionscript.org/forums/showthread.php3?t=151850

Thanks.
BimibearAuthor
Inspiring
March 20, 2009
combustion007,

Thanks for the reply...
I found the following code in a book which I have been able to implement, however I can't get the external swf to disappear after playing... any ideas?

I am such a newbie with Actionscript - but I am determined to keep trying