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