A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: How to make an objekt follow the cursor in a menu?

  1. #1
    Junior Member
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    8

    How to make an objekt follow the cursor in a menu?

    Hi everyone!

    I`m very new in flashscripting and in scripting what so ever!
    I have a large homepage projekt i`ve been working on for a very
    long time so now i have most of the peices and animations done,
    But i cant script and do interactivity im very novice in that.

    So straight to the thing! I wonder how you make an objekt
    follow the cursor when you navigate thruegh a menu insted
    of the usual that a link highlights on mouseover or change color.
    It shall ONLEY apear on mouse over with an infade and as i said
    it shall follw the cursor BUT!!! I want it to be a little rubberband
    effekt. And as the user takes the cursor away it fades away softly!

    I have an almost perfekt example of a swedish homepage that i found.
    Check out the pink underline that follows the cursor.

    http://markus-2.rah.se/index.asp

    Someone mentioned it could be enterFrame script
    with x_mouse and y_mouse but it didn`t work!
    But well its as most the scripting i do cause im new in it!

    Help!!!

  2. #2
    Senior Member
    Join Date
    May 2002
    Posts
    1,017
    Quote Originally Posted by FlashyTheKid!
    Someone mentioned it could be enterFrame script
    with x_mouse and y_mouse but it didn`t work!
    But well its as most the scripting i do cause im new in it!

    Help!!!
    They were right it's only _xmouse and _ymouse
    while (2+2 == 4) {
    drink ("bourbon");
    }
    gotoAndStop("bed");

  3. #3
    Junior Member
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    8
    Quote Originally Posted by Smilev
    They were right it's only _xmouse and _ymouse
    Ok! But i tried and tried but failed and failed and still am!
    Hmm so do you have an example of a whole script about
    _xmouse and _ymouse ?

    and well i dont know if done something
    wrong in flash? Maybe mist an instance name
    just for an example? But i dubbelchecked
    so it must be some error in the code?

    I Just cant make it work!!!

  4. #4
    Senior Member
    Join Date
    May 2002
    Posts
    1,017
    It's fairly easy. I guess they are doing somethign liek this
    Attached Files Attached Files
    while (2+2 == 4) {
    drink ("bourbon");
    }
    gotoAndStop("bed");

  5. #5
    Junior Member
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    8
    Quote Originally Posted by Smilev
    It's fairly easy. I guess they are doing somethign liek this
    Wow! Yes! Thankyou you made me very happy!
    Now ill take it to the next level in my own design.

  6. #6
    Junior Member
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    8
    Quote Originally Posted by Smilev
    It's fairly easy. I guess they are doing somethign liek this
    Hi there again! Do you know a script to increase the speed of the objekt that follows follows the mouse? You know the swf you sent me example_smooth_follow_mouse

    I tried taking different actions from other swf doks that relates to speed/velocty and pasted it in the swf but i doesn`t work.
    i tried this action for example speed = 5;



    And!!! Important!!!
    In the swf file I´m working on has 2 link menus so i tried to duplikate the script
    of follow the mouse but it did`nt work that iether. Seems as if they colide and
    onley one of the exactly the same script can work???

  7. #7
    Junior Member
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    8
    Quote Originally Posted by Smilev
    It's fairly easy. I guess they are doing somethign liek this
    Never Mind i just succeded this time i put the action in this
    _root.ornament._x -= speed = 10;((_root.ornament._x*2)/(_root._xmouse));

    As you see speed = 10;

    Well i`ll see if i could do the rest i asked you about!

  8. #8
    Senior Member
    Join Date
    May 2002
    Posts
    1,017
    Hi, here is the chnaged movie.
    I put some comments about the speed in the the code.
    Attached Files Attached Files
    while (2+2 == 4) {
    drink ("bourbon");
    }
    gotoAndStop("bed");

  9. #9
    Junior Member
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    8
    Quote Originally Posted by Smilev
    Hi, here is the chnaged movie.
    I put some comments about the speed in the the code.
    Hi again! And thanks again your really saving my future carrer!
    I maneged now to make 2 menus as you sent me, but there is a slight error
    in the code you sent me. The blueline shows in a short sekond in the very beginning and fades to alpha 0.

    And 2 other things i wonder about!
    Is it possible that you know a code that can make the line apear exaktly where you put the cursor? For example if you mouse is over the link test3 and the cursor begins there and of course follows the mouse as usual in the way it goes now that im very pleased about.

    The second thing! When the line stops att the link you are on if it could just slightly be off balance (rocks little back a and fourth very slightly)untill it stops in exact position. Like a feel of a rubber band.

  10. #10
    Junior Member
    Join Date
    Apr 2007
    Posts
    16
    hey smilev,

    I've just spent the last hour tralling though posts and movine file on flash kit and I found this post which is the nearest to what I'm looking for.

    Basically I've checked this movie file but I need my version to snap to an object or the text when it lands on it.

    Do you know what the code would be to add this small feature?

    Many thanks
    Droppenkiken
    -----------------------
    http://www.myspace.com/thedropkickproject

  11. #11
    Senior Member
    Join Date
    May 2002
    Posts
    1,017
    Err sorry, I am not sure I understand what do you want. What should snap and what lands where?
    while (2+2 == 4) {
    drink ("bourbon");
    }
    gotoAndStop("bed");

  12. #12
    Senior Member
    Join Date
    Apr 2007
    Posts
    161
    Quote Originally Posted by Droppenkiken
    hey smilev,

    I've just spent the last hour tralling though posts and movine file on flash kit and I found this post which is the nearest to what I'm looking for.

    Basically I've checked this movie file but I need my version to snap to an object or the text when it lands on it.

    Do you know what the code would be to add this small feature?

    Many thanks
    Droppenkiken
    -----------------------
    http://www.myspace.com/thedropkickproject
    sounds like your looking for: hitTest();

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