I’m loading swf externally. I need to access it’s methods and variables. This is the code I’m using:
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.display.MovieClip;
var loader:Loader;
var req:URLRequest = new URLRequest("aaa.swf");
var mc:MovieClip;
createLoader();
function createLoader():void {
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, onSWFLoad);
loader.load(req);
}
function onSWFLoad(e:Event):void {
mc = MovieClip(loader.content);
addChild(mc);
trace(loader.content)
}
EM is loaded SWF’s document class. If questioned if variable gameEnded is declared publicly, the answer is yes. The game loads, but there is an error when calling the variable :
ReferenceError: Error #1069: Property gameEnded not found on EM__Preloader__ and there is no default value.
at main_fla::MainTimeline/onSWFLoad()
It turned out that I had to embed all the code in SWF (I was using some TLF in it)