0
我有一個忍者星級。As3:_root.removeChild(this)不適用於數組特定的情況下?
在循環功能,我有:
private function loop (event:Event):void
{
trace(this);
for (var i:int=0; i<_root.guardArray.length; i++)
{
//if movieClip at position [i] (enemy) hits this
if (_root.guardArray[i].hitTestObject(this))
{
if(this.hitTestObject(_root.guardArray[i].hitbox))
{
_root.guardArray[i].killThis();
_root.removeChild(this);
removeEventListener(Event.ENTER_FRAME, loop);
}
}
}
y-=Math.cos(rotation/-180*Math.PI)*(ninjaStarSpeed);
x-=Math.sin(rotation/-180*Math.PI)*(ninjaStarSpeed);
if(this.x < 0 || this.x > _root.stagewidth || this.y > _root.stageheight || this.y < 0)
{
_root.removeChild(this);
removeEventListener(Event.ENTER_FRAME, loop);
}
}
}
的飛鏢成功刪除本身沒有任何錯誤,當它熄滅的畫面。
但是,當它打到警衛時,它會自行移除,但會給我一個#2025錯誤@第40行!
這是第40行:_root.removeChild(this); - 它是數組碰撞檢查的一部分。
閃存錯誤或我正在做什麼非常錯誤?
THANK YOU !!!!!!!!!!!!!!!!!!!!!!!! :D – user3123633
我愛你這麼多! :d – user3123633