A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Mouse tracking help

  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    24

    Mouse tracking help

    I have a movieclip on the stage that's acting as a mask with an instance name of 'mask_mc'. It's a 160x600 box.

    I would like to have an onEnterFrame function, that tracks the mouse's Y position and sets mask_mc to that position value minus 160 (so the bottom of my mask lines up with the mouse).

    I also was wondering if there's a way to track when the mouse has left the stage, and if so, have it automatically set the mask_mc to a given position, [0,-279].

  2. #2
    Junior Member
    Join Date
    Nov 2008
    Posts
    24
    I figured out how to get the mc to follow my cursor with this code...

    Code:
    this.onMouseMove = function() { 
    this.mask2_mc._y=_root._ymouse-600; 
    this.stripe_mc._y=_root._ymouse; 
    //trace(_root._ymouse);
    updateAfterEvent(); 
    };

    Now I need to have the mc's snap back to a given spot when the user mouses out. Any help there?

  3. #3
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    You can't check if mouse has left screen in Actionscript 2.0, only in Actionscript 3.0
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  4. #4
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Put an empty movieclip on the bottom layer, and put an on enterFrame with an onRollOut=function(){
    //Mouse is out of the movieclip, therefore is out of the stage, DO THIS
    }

    and onRollOver=function(){
    //Mouse is over the movieclip, therefore is inside the stage, DO THIS
    }

    *I have not tested it, but it sh ould work.
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

Tags for this Thread

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