Loader flash calls a function from the loaded flash

let’s imagine this scenario:
A.swf loads B.swf
after load is completed,A.swf needs to execute a function in B.swf called runCommands() for example.. here is the code for that (this is the code inside A.swf):

import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.*;
import flash.net.URLRequest;

...

var loaderRequest:URLRequest = new URLRequest("B.swf");
var movieLoader:Loader = new Loader();
movieLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
movieLoader.load(loaderRequest)....

function completeHandler(_event:Event)
{

	var _loaderInfo:LoaderInfo = _event.target as LoaderInfo;
	var loadedObject:Object = _loaderInfo.content;
	loadedObject.runCommands()
}
  1. Diego says:

    Thank you!

    …but I have the opposite problem :)

    I’d want to call a function in A from B.

    Are you able to do it? thanks!

  2. slaughter says:

    thanks !

    i was looking for what data type the loaded object was. (var loadedObject)
    turns out its an object. i was tryingeverything but
    Thanks!

  1. There are no trackbacks for this post yet.

Leave a Reply