我在舞台上有一个按钮,它使用 Loader 类加载外部 SWF。我希望能够在用户单击 SWF 外部(即舞台上的其他任何位置)时卸载它。
到目前为止,我只有加载 SWF 的代码......
mybutton.addEventListener(MouseEvent.CLICK, fl_LoadExternalSwf);
function fl_LoadExternalSwf(event:MouseEvent):void
{
var my_Loader:Loader = new Loader();
var my_url:URLRequest=new URLRequest("pageFlip.swf");
//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(my_url);
//This function adds the external SWF to the stage.
function finishLoading(loadEvent:Event) {
addChild(loadEvent.currentTarget.content);
}
//This function displays a message if the file is not found.
function errorHandler(errorEvent:Event):void {
trace("file missing");
}
}