Posted By

Winkyboy on 05/19/09


Tagged

load movieclip addChild loader as3


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

loric
tspitzr
jondiscipulo


AS3 Loader


 / 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.

  1. // Define a variable to reference your exported-for-actionscript
  2. // library element. Just create an empty movieclip and set its
  3. // export-for-actionscript property appropriately
  4. var header_mc:mc_holder = new mc_holder();
  5.  
  6.  
  7.  
  8. function init():void
  9. {
  10. /////////////////////////////////////////// BEGIN Add Header
  11. var loadHeader = new Loader(); // temporary variable to reference the Loader class
  12. addChild(header_mc); // add our holder
  13. header_mc.addChildAt(loadHeader,0); // (You could just use addChild)
  14. loadHeader.contentLoaderInfo.addEventListener(Event.COMPLETE, positionHeader);
  15. loadHeader.load(new URLRequest("loadee.swf"));
  16. /////////////////////////////////////////// END Add Header
  17. }
  18.  
  19. function positionHeader(e):void
  20. {
  21. header_mc.x = stage.stageWidth/2 - header_mc.width/2;
  22. header_mc.y = stage.stageHeight/2 - header_mc.height/2;
  23. }
  24.  
  25. init(); // Make it so.

Report this snippet  

You need to login to post a comment.