我只是在學習ActionScript 3,所以這對你的親們來說可能是一個簡單的問題。 我使用按鈕創建了我想添加到舞臺(從庫中)的影片剪輯。我總共有六個按鈕(和六個moviclips),但我試圖在開始下一個按鈕之前讓前兩個按鈕工作。問題是,我似乎無法刪除當另一個按鈕被點擊或相同的按鈕時刪除影片剪輯...就像我說我是新來的,我認爲創造了一堆東西......我得到錯誤2007現在ActionScript 3 - 添加和刪除舞臺上的孩子
import flash.events.MouseEvent;
import flash.display.MovieClip;
mix_btn.addEventListener(MouseEvent.CLICK, addbear);
function addbear(event:MouseEvent):void
{
var movieClip:bear1 = new bear1();
addChild(movieClip);
movieClip.x = 240;
movieClip.y = 45;
mix_btn.removeEventListener(MouseEvent.CLICK, addbear);
mix_btn.addEventListener(MouseEvent.CLICK, removebear);
}
function removebear(event:MouseEvent):void
{
var movieClip:bear1 = null;
removeChild(movieClip);
mix_btn.removeEventListener(MouseEvent.CLICK, removebear);
/* mix_btn.addEventListener(MouseEvent.CLICK, addbear);*/
}
shake_btn.addEventListener(MouseEvent.CLICK, addbear3);
function addbear3(event:MouseEvent):void
{
var movieClip:bear3 = new bear3();
addChild(movieClip);
movieClip.x = 240;
movieClip.y = 45;
shake_btn.removeEventListener(MouseEvent.CLICK, addbear3);
shake_btn.addEventListener(MouseEvent.CLICK, removebear3);
}
function removebear3(event:MouseEvent):void
{
var movieClip:bear3 = null;
removeChild(movieClip);
shake_btn.removeEventListener(MouseEvent.CLICK, removebear3);
shake_btn.addEventListener(MouseEvent.CLICK, addbear3);
}
只要將其添加到顯示列表中,它就不能「消失」。不僅如此,他使用2個不同的局部變量,所以當然不是這樣。 – 2011-04-11 17:00:53