Loading an External .swf in AS3

Here’s a simple example of loading a .swf in AS3. I had a typo before but now it’s fixed - sorry about that. Also, I updated it so you don’t have to strictly use it in an Class setting.

Happy Coding…

import flash.net.URLRequest; import flash.display.Loader; import flash.events.Event; import flash.events.ProgressEvent; function startLoad() { var mLoader:Loader = new Loader(); var mRequest:URLRequest = new URLRequest(“MouseActions.swf”); mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler); mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler); mLoader.load(mRequest); } function onCompleteHandler(loadEvent:Event) {         addChild(loadEvent.currentTarget.content); } function onProgressHandler(mProgress:ProgressEvent) { var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal; trace(percent); } startLoad();

del.icio.us Slashdot Digg Facebook Technorati Google Yahoo


About this entry