/ Published in: ActionScript 3

URL: http://dl.getdropbox.com/u/316550/code-AS3-loader.zip
A simple, well-commented script with a working example of how to load an external SWF into Flash using actionscript3.
Expand |
Embed | Plain Text
// Define a variable to reference your exported-for-actionscript // library element. Just create an empty movieclip and set its // export-for-actionscript property appropriately var header_mc:mc_holder = new mc_holder(); function init():void { /////////////////////////////////////////// BEGIN Add Header var loadHeader = new Loader(); // temporary variable to reference the Loader class addChild(header_mc); // add our holder header_mc.addChildAt(loadHeader,0); // (You could just use addChild) loadHeader.contentLoaderInfo.addEventListener(Event.COMPLETE, positionHeader); loadHeader.load(new URLRequest("loadee.swf")); /////////////////////////////////////////// END Add Header } function positionHeader(e):void { header_mc.x = stage.stageWidth/2 - header_mc.width/2; header_mc.y = stage.stageHeight/2 - header_mc.height/2; } init(); // Make it so.
You need to login to post a comment.