the thinBlog

Wednesday, September 19, 2007

AS 3 Example: Calling methods of a loaded SWF File.

So I am working on a project that loads in SWF file that needed a parameter to load in some external data. Now with AS3 you can’t really just call the method directly from the loaded object like you would in AS2. I posted the example below.



var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
var url:String = "URL_OF_SWF.swf";
var urlReq:URLRequest = new URLRequest(url);

ldr.load(urlReq);
addChild(ldr);

function initHandler(e:Event):void
{
var ml = ldr.content;
var urlReq:URLRequest = new URLRequest("URL_FOR_XML_REQUEST");
ml.init(urlReq);
}


I also have a zip of the example for download.

Labels: ,

posted by Romke de Haan at 10:01 PM

0 Comments:

Post a Comment

<< Home