-2
我試圖加載和卸載許多外部swf文件到主空白swf中。並使用位於外部加載的子頁面上的導航按鈕(next/back)來導航(加載和卸載頁面)。加載多個外部swf並使用兒童上的按鈕導航
我試圖從小孩派遣事件到主要卸載。它只適用於第一頁,因爲調度員只冒泡一次。
我必須加載默認的頁面和調度聽衆在主SWF如下:
var cont:Sprite= new Sprite();
var swfLoader:Loader = new Loader();
var swfFile:URLRequest = new URLRequest("Page1.swf"); //default page
addChild(cont);
swfLoader.load(swfFile);
cont.addChild(swfLoader);
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoadedHandler);
function swfLoadedHandler(event:Event):void {
MovieClip(event.currentTarget.content).addEventListener("eventTriggered", removeLoader);
}
function removeLoader(event:Event):void {
SoundMixer.stopAll();
this.swfLoader.unloadAndStop();
this.removeChild(cont);
this.cont = null;
swfLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, swfLoadedHandler);
trace ("dispatched");
}
而且對兒童page1.swf Next按鈕的代碼是follwos:
nxt_pg.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_8);
function fl_MouseClickHandler_8(event:MouseEvent):void {
content_mc.gotoAndStop(1);
dispatchEvent(new Event("eventTriggered", true));
SoundMixer.stopAll();
//Code of Loading new page here
}
和後退按鈕相同的代碼。
所以,我想知道是否有人可以幫助我的代碼或更好的技術..提前感謝您的幫助。