开发者

how can i get MC in stage function?

i create three circles. if a circle is dragged to right side of the stage, it becomes invisible and vice versa. when MOUSE_UP is invoked, it must stay in its last position.

so in the appear() function how can i assign the selected circle to 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
{
 开发者_C百科   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);
}


I am a little confused. You assign current_mc in your downFNK, so then in your appear function it should still be assigned.

Also, instead of listening for Event.ENTER_FRAME, you should change it to listen for MouseEvent.MOUSE_MOVE.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜