Load External SWFs, addChild(Loader) vs. addChild(Loader.content), etc.
Hello All,
After doing a lot of reading on loading external assets, the Loader class, etc. I just need some clarification and maybe a little guidance.
I have a main "shell" swf which, by clicking several buttons, will load/unload various external swfs into a Placeholder_mc which resides on the main timeline in Shell.swf
In the documentation and tutorials I've seen a couple different methods, and I'm not sure I quite understand the difference, or at least the reason you would use one over the other...
In the 1st method, you can just add the Loader object using the addChild() method:
Code:
var myLoader:Loader = new Loader();
var myURLRequest:URLRequest = new URLRequest("ExternalFileA.swf");
myLoader.load(myURLRequest);
Placeholder_mc.addChild(myLoader);
This will apparently add myLoader to the display list once it has completely loaded.
The 2nd method, you supposedly can add the Loader.content; however, it appears you can only do this once the content has completed loading, so you need to incorporate an event handler with the contentLoaderInfo object:
Code:
var myLoader:Loader = new Loader();
var myURLRequest:URLRequest = new URLRequest("ExternalFileA.swf");
myLoader.load(myURLRequest);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, Loaded);
function Loaded(evt:Event):void{
Placeholder_mc.addChild(myLoader.content);
}
What are the pros/cons of adding the entire Loader object, as opposed to the Loader.content and vice versa??
loading 2 swf with 1 swf is over 2 swf
Hi
I am just started using Flash CS4 / AS3.
I am loading 2 swf files in another flash file
see http://64.131.70.95/~archit/flashdemo/final.html
1st swf is also created by actionscript 3
2nd swf (cloud scene) is created by actionscript 3
Now I am loading both swf in final flash file.
1st swf in layer 3(above layer1). Action has following script
==================================
var myLoader:Loader = new Loader();
addChild(myLoader);
var url:URLRequest = new URLRequest("CloudExampleLogoCS3Final.swf");
myLoader.load(url);
=======================================
2nd swf in layer 1(below layer3). Action has following script
==================================
var myLoader1:Loader = new Loader();
addChild(myLoader1);
var url1:URLRequest = new URLRequest("CloudExampleCS3Final.swf");
myLoader1.load(url1);
=======================================
I want 1 swf is above 2 swf. (Text above cloud).
How to do this?
Earlier we used level in early version of flash but it is removed from AS3.
Thx