移除置入的SWF

以按鈕連結至特定影格後再loaderSWF(置放於特定區域),之後在原影格以任何的按鈕連結至各影格,SWF都會陰魂不散,快瘋了...

以下是寫在展示SWF影格上的程式:

var fileURL:URLRequest=new URLRequest('211照片輪播材料.swf');

var loader:Loader=new Loader;

loader.load(fileURL);

this.addChild(loader).x=85;

this.addChild(loader).y=175;

1 Answer

Rating
  • ALESSI
    Lv 6
    1 decade ago
    Favorite Answer

    你可以用unload()去關掉以開啟的檔案

    以下用開啟兩個檔案的AS3為範例(而了個按鈕的名稱分別為ani1_btn,ani2_btn:

    ps.範例重複性高,你可以用迴圈或陣列方式去簡化AS3,在此就不做簡化動作

    var req1:URLRequest = new URLRequest("ani1.swf");

    var req2:URLRequest = new URLRequest("ani2.swf");

    var loader1:Loader = new Loader();

    var loader2:Loader = new Loader();

    var posX:int = 85;

    var posY:int = 175;

    loader1.x = loader1.x = posX;

    loader2.x = loader2.x = posY;

    function showAni1(event:MouseEvent):void {

    loader1.load(req1);

    addChild(loader1);

    loader2.unload();

    }

    function showAni2(event:MouseEvent):void {

    loader2.load(req2);

    addChild(loader2);

    loader1.unload();

    }

    ani1_btn.addEventListener(MouseEvent.CLICK, showAni1);

    ani2_btn.addEventListener(MouseEvent.CLICK, showAni2);

    2009-05-01 20:27:54 補充:

    以上範例只需一個影格

    Source(s): Adobe flash, adobe flash
Still have questions? Get your answers by asking now.