忍者スターのクラスがあります。
ループ関数には、次のものがあります。
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);
}
}
}
忍者の星は、画面の外に出たときにエラーなく正常に削除されます。
ただし、ガードにヒットすると、それ自体は削除されますが、40 行目で #2025 エラーが発生します。
これは 40 行目です: _root.removeChild(this); - 配列の衝突チェックの一部です。
フラッシュがバグっていますか、それとも私が何か非常に間違ったことをしていますか?