A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: run away from cursor

  1. #1
    Flashkit Witch Azaraelle's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    123
    I want to create a button/graphic/mc that moves away if the cursor goes near it, as if repelled/being chased by the cursor. How do I do this?

  2. #2
    deva_station
    Guest
    this may be something like what you're looking for its a movieclip event handler - of course.

    Code:
    onClipEvent(enterFrame){
    dx=_root._xmouse-this._x;
    dy=_root._ymouse-this._y;
    od=Math.sqrt((dx*dx)+(dy*dy));
    if (od<300){
    this._x=this._x+(od/30);
    this._y=this._y+(od/30);
    }
    }
    this should provide you with a bit of inspiration for your particular assignment.

  3. #3
    Flashkit Witch Azaraelle's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    123
    thanks, I will try it.

  4. #4
    Flashkit Witch Azaraelle's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    123
    Okay, how do I stop it from moving out of the screen? Also, how do I get it to move in all directions instead of just one?

  5. #5
    Infinite Loop grvdgr's Avatar
    Join Date
    Feb 2001
    Posts
    610
    Hello,
    Only looked at this for a short while,not sure exactly what your shooting for, but maybe something like this............

    onClipEvent (enterFrame) {
    xdif = _x-_root._xmouse;
    ydif = _y-_root._ymouse;
    _x -=- xdif/10;
    _y -= -ydif/10;
    }


    Hope it helps

    Regards
    ~GD~

  6. #6
    Flashkit Witch Azaraelle's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    123
    Thanks, How do I stop it from leaving the screen? And, can I make the movements more jerky? I want it to be absolutely 100% unclickable... so that the cursor simply cannot touch the button/mc.

  7. #7
    Flashkit Witch Azaraelle's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    123
    still no takers?

  8. #8
    Infinite Loop grvdgr's Avatar
    Join Date
    Feb 2001
    Posts
    610
    Hi again,
    Sorry, got a little side tracked on a few things. Here is an fla you might want to take a look at, attatch one of the MC's to the mouse pointer and set the visibility to false ( or alpha to 0) and it should do just what you were asking.............
    http://caveart.tv/magnetism2.fla

    Hope it helps
    Regards
    ~GD~

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