Loader クラスを使用して外部 SWF をロードするボタンがステージ上にあります。ユーザーが 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");
}
}