A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: stoping a movie clip on its current x position action script 3

  1. #1
    Junior Member
    Join Date
    Jun 2001
    Posts
    13

    stoping a movie clip on its current x position action script 3

    I have a mc that I am moving along the x axis dynamically. When it reaches a certain point it resets to 0 x.
    I would like to stop the movement of the mc (on it's current x position) on mouse over and restart on mouse out.

    Thanks in advance for your help.

    Here is my code so far:

    addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler_5);

    function fl_EnterFrameHandler_5(event:Event):void
    {

    this.myObject.x += -1;
    if (this.myObject.x == -1)
    {
    this.myObject.x = 110;
    }

    }

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    var isOver:Boolean = false;
    myObject.addEventListener(MouseEvent.MOUSE_OVER, doOver);
    myObject.addEventListener(MouseEvent.MOUSE_OUT, doOut);
    
    addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler_5);
    
    function fl_EnterFrameHandler_5(event:Event):void {
            if (isOver == false) {
                    this.myObject.x +=  -1;
                    if (this.myObject.x == -1) {
                            this.myObject.x = 110;
                    }
            }
    }
    function doOver(event:Event):void {
            isOver = true;
    }
    function doOut(event:Event):void {
            isOver = false;
    }

  3. #3
    Junior Member
    Join Date
    Jun 2001
    Posts
    13

    thanks so much!

    Thank you so much this works perfectly!
    If I may ask a question to how this works. I understand the boolean is either off or on. I understand and see if the condition is false my animation is working. What I don't see is how you tell the animation to stop at the current x position if the condition is true.

    Again, thanks again for your help it is so appreciated.

    Quote Originally Posted by dawsonk View Post
    Code:
    var isOver:Boolean = false;
    myObject.addEventListener(MouseEvent.MOUSE_OVER, doOver);
    myObject.addEventListener(MouseEvent.MOUSE_OUT, doOut);
    
    addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler_5);
    
    function fl_EnterFrameHandler_5(event:Event):void {
            if (isOver == false) {
                    this.myObject.x +=  -1;
                    if (this.myObject.x == -1) {
                            this.myObject.x = 110;
                    }
            }
    }
    function doOver(event:Event):void {
            isOver = true;
    }
    function doOut(event:Event):void {
            isOver = false;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center