Return to Snippet

Revision: 49901
at August 1, 2011 21:46 by tuffstudio


Initial Code
//This creates a new instance of the loader object.
var my_Loader:Loader = new Loader();

var my_loadedSwf:MovieClip;

//These listeners detect when the file has finished loading, and if the correct file is 
//loaded.
my_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
my_Loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);

//The load method then loads the SWF file into the loader object.
my_Loader.load(new URLRequest("mouseover2.swf"));

//This assigns the loaded SWF into a variable which allows the testing() function to be called.
function finishLoading(loadEvent:Event) {
my_loadedSwf = loadEvent.currentTarget.content;

addChild(my_loadedSwf);

my_loadedSwf.testing();
}

function errorHandler(errorEvent:Event):void {
trace("file not found");
}

Initial URL

                                

Initial Description
The code below assume you have a method in your external SWF called testing().

Initial Title
Call function from external SWF in AS3

Initial Tags

                                

Initial Language
ActionScript 3