views:

34

answers:

1

hi, 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
{
    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);
}
+1  A: 

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.

Allan
you are right, i solved it. i just began learning flash one week ago, so i don't know some useful properties yet. thanks...
ok. Good luck with the learning :)
Allan