Load an external swf, use it and gain access to its functions and features.


/ Published in: ActionScript 3
Save to your folder(s)

How to load an external swf. Once its loaded, access it and use its functions and variables.


Copy this code and paste it in your HTML
  1. function SourceMovie():void
  2. {
  3. var loader:Loader = new Loader();
  4. loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
  5. loader.load(new URLRequest('importedSwf.swf'));
  6. }
  7. function onLoadComplete(e:Event):void {
  8. var loaderInfo:LoaderInfo = e.target as LoaderInfo;
  9. addChild(e.target.content);
  10. var swf:Object = loaderInfo.content;
  11. swf.changeText();
  12. }
  13.  
  14. SourceMovie();
  15.  
  16.  
  17. // Runs function called changeText inside imported swf.
  18. // To access variables, change "changeText()" to the variable name.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.