Posted By

tuffstudio on 04/15/12


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ahmetalsan


call a function from external swf


 / Published in: ActionScript 3
 

code below assumes you have method testing() in external swf.

  1. //This creates a new instance of the loader object.
  2. var my_Loader:Loader = new Loader();
  3.  
  4. var my_loadedSwf:MovieClip;
  5.  
  6. //These listeners detect when the file has finished loading, and if the correct file is
  7. //loaded.
  8. my_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
  9. my_Loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
  10.  
  11. //The load method then loads the SWF file into the loader object.
  12. my_Loader.load(new URLRequest("mouseover2.swf"));
  13.  
  14. //This assigns the loaded SWF into a variable which allows the testing() function to be called.
  15. function finishLoading(loadEvent:Event) {
  16. my_loadedSwf = loadEvent.currentTarget.content;
  17.  
  18. addChild(my_loadedSwf);
  19.  
  20. my_loadedSwf.testing();
  21. }
  22.  
  23. function errorHandler(errorEvent:Event):void {
  24. trace("file not found");
  25. }

Report this snippet  

You need to login to post a comment.