我创建了三个圆圈。如果将一个圆圈拖到舞台的右侧,它将变为不可见,反之亦然。当调用MOUSE_UP时,它必须保持在其最后位置。
所以在appear()函数中如何将选定的圆分配给current_mc?
function createCircles(evt:Event):void
{
for(i=0; i<3; i++)
{
var figure:Sprite=new Sprite();
figure.circle.x=10;
figure.circle.y=i*figure.circle.height*1.02;
figure.circle.buttonMode=true;
figure.circle.addEventListener(MouseEvent.MOUSE_DOWN,downFNC);
addChild(figure.circle);
}
}
function downFNK(evt:MouseEvent):void{
current_mc=MovieClip(evt.target);
current_mc.x=mouseX;
current_mc.y=mouseY;
stage.addEventListener(Event.ENTER_FRAME,appear);
}
function appear (evt:Event):void
{
current_mc=???
current_mc.x=mouseX;
current_mc.y=mouseY;
if(mouseX > stage.width/2)
current_mc.visible=false;
else
current_mc.visible=true;
stage.addEventListener(MouseEvent.MOUSE_UP, upFNC);
}
function upFNC(evt:MouseEvent):void
{
stage.removeEventListener(Event.ENTER_FRAME, appear);
}
答案 0 :(得分:1)
我有点困惑。你在downFNK中分配current_mc,那么在你的出现函数中它仍应被分配。
此外,您应该更改它以侦听MouseEvent.MOUSE_MOVE而不是侦听Event.ENTER_FRAME。