我在删除舞台上的实例时遇到了麻烦。
单击按钮 2 次后我不断收到的错误是
“提供的 DisplayObject 必须是调用者的子对象”
有人可以帮我吗?
package src
{
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.Event;
import flash.events.MouseEvent;
public class Main extends MovieClip
{
var positionY:Number = 80;
var positionX:Number = 0;
var motion:MovieClip;
var fCombo:Array = new Array();
var n:Number;
public function Main()
{
generate.addEventListener(MouseEvent.MOUSE_UP, loop);
generate.addEventListener(MouseEvent.MOUSE_DOWN, remove);
n = Number(inputText.text);
}
function loop(me:MouseEvent):void
{
var combo:Array = [Punch, Kick, Knee, Elbow];
n = Number(inputText.text);
for(var i:Number = 0;i < n;i++ )
{
motion = new combo[randomNumber(4)]();
fCombo.push(motion);
motion.y = positionY;
motion.x = positionX;
positionX += 100;
addChild(motion);
if (i == 4 || i == 9 || i == 14)
{
positionY += 40;
positionX = 0;
}
}
}
function remove(me:MouseEvent):void
{
for (var j:Number = 0; j < n; j++ )
{
removeChild(fCombo[j]);//error
}
positionY = 80;
positionX = 0;
}
function randomNumber(max:Number):Number
{
return(Math.floor(Math.random() * max ));
}
}
}