A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: MC to follow Cursor

  1. #1
    Junior Member
    Join Date
    Feb 2005
    Posts
    8

    MC to follow Cursor

    I've got an MC that follows my cursor, but it follows it for everywhere that my cursor is on the page. I want to to only follow my cursor if it is in a specified area. (I'm making a horizontal nav bar (2 rows, bottom row is submenu) and I only want it to follow while the cursor is over the top of the root menu (the one on top). Here is the code that I have so far.

    onClipEvent (enterFrame) {
    //x movement
    mx=_root._xmouse-50;
    if (mx<_x) {
    dx=_x-mx;
    }
    else {
    dx=mx-_x;
    }
    moveSpeedx=dx/2;
    if (mx<_x) {
    _x=_x-moveSpeedx;
    }
    else {
    _x=_x+moveSpeedx;
    }
    }


    I'm using Flash MX2004. I just don't know enough about how to specify the boundries. Thanks.

  2. #2
    Member
    Join Date
    Jan 2005
    Posts
    60
    Do you have a flash 5 file FLA? Also, you can try the hitTest method...

  3. #3
    Senior Member Cass101's Avatar
    Join Date
    Dec 2004
    Posts
    131
    Here's something I just knocked together quickly that might help.

    Uses the mouse following code from here:
    http://actionscript.org/tutorials/ad...se/index.shtml
    so visit there for an explanation of the movement code, I just added the if statement for the coordinates of the box.

    Hope it helps.
    Attached Files Attached Files

  4. #4
    Junior Member
    Join Date
    Feb 2005
    Posts
    8
    Perfect. Thanks so much.

  5. #5
    Junior Member
    Join Date
    Nov 2010
    Posts
    1
    I read this and wondered how you get the object to follow it everywhere.

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