2

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");
}
}
4

1 に答える 1

0

クラスunload()の_Loader()

function unloadMC(myLoader:Loader, myURL:URLRequest):void {
 myLoader.unLoad(myURL);
}

unloadMC(my_Loader, my_url);

編集

swfを「除いて」クリックイベントを呼び出すには、外部インターフェイスが必要です。まず、jQueryを使用して達成する必要があります

$(document).bind('click', function (e) {
 $('#yourSWFObject').clickOutside();
});

$('#special').bind('click', function(e) {
    e.stopPropagation();
});

クリック法。その後、AS3 から externalInterface を適用する必要があります。

import flash.external.ExternalInterface;
public function clickOutside() {
 unloadMC(my_Loader, my_url);
} 
于 2012-11-24T12:33:27.457 に答える