I have a two files: Main.swf and DataEnter.swf. Each has a Document Class. I try to load DataEnter.swf in Main.swf.
Main.as
package
{
import flash.events.*;
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.display.Loader;
public class Main extends MovieClip
{
public function Main()
{
var loader: Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, DataEnter_loadComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
loader.load(new URLRequest('DataEnter.swf'));
}
function DataEnter_loadComplete(evt: Event):void
{
trace(evt.target.content); // DataEnter__Preloader__
var SWF = evt.target.content;
SWF.FooBar(); //Error #1069: Property FooBar not found on DataEnter__Preloader__ and there is no default value
}
}
}
DataEnter.as
package
{
import flash.display.Sprite;
public class DataEnter extends Sprite
{
private var _socketWorker:Foo;
public function setSocketWorker(sw:Foo)
{
_socketWorker = sw;
}
public function FooBar()
{
//do something
}
}
}
When occurs an event Event.COMPLETE of Loader in Main class, the evt.target.content contains object DataEnter_Preloader_. But it must be "DataEnter".
What is wrong? How to call method FooBar of Loaded Class ?