[英]Flash AS3 advance to next frame with hitTestObject
大家好,在這里需要一些幫助。 基本上我想在(guy1)命中hitTestObject(home1_mc)之后前進到第4幀。
這是我得到的錯誤:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at DNAGames2_fla::MainTimeline/exitFrameHandler()
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at DNAGames2_fla::MainTimeline/exitFrameHandler()
這是我的代碼:
function exitFrameHandler(event:Event):void{
if(guy1.hitTestObject(home1_mc)) {
removeChild(guy1);
removeChild(guy2);
removeChild(guy3);
removeChild(o1);
removeChild(cherry1);
gotoAndStop(4);
}
}
我嘗試移除孩子的原因是由於我在切換游戲菜單后仍在屏幕上。 任何幫助表示贊賞
也許您還應該添加處理程序:
removeEvetListener(EVENT_TYPE, exitFrameHandler);
如果偵聽器被調用兩次,您將得到確切的錯誤-因為它第一次刪除子級,而第二次嘗試刪除不再是容器子級的顯示對象。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.