SWF files are loaded using the Loader class:
1.Create a new URLRequest object with the url of the file.
2.Create a new Loader object.
3.Call the Loader object's load() method, passing the URLRequest instance as a parameter.
4.Call the addChild() method on a display object container.
Extract class reference by using:
var C:Class= loader.contentLoaderInfo.applicationDomain.getDefinition("ClassName") as Class;
package
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.events.Event;
import flash.net.URLRequest;
import flash.utils.getQualifiedClassName;
import mx.core.UIComponent;
public class SwfTest extends UIComponent
{ private var loader:Loader;
public function SwfTest()
{
super();
var request:URLRequest = new URLRequest("swf file location");
loader= new Loader()
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderReady);
loader.load(request);
}
public function onLoaderReady(e:Event):void {
var C:Class= loader.contentLoaderInfo.applicationDomain.getDefinition("ClassName") as Class;
var m:MovieClip = new C();
//m.gotoAndStop(1);
// m.gotoAndStop(1);
this.addChild(m);
}
}
}
1 Comment(s)