A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 23

Thread: Mouse follow nav bar

  1. #1
    Member
    Join Date
    Aug 2001
    Posts
    36
    Pls help

    I have this arrow which i wish to move from left to right according to the mouse location and stop following when the mouse moves to a certain location. Therefore I tried adding the following to the arrow symbol

    Code:
    onClipEvent (enterFrame) {
    	startDrag(getProperty(_x, _y), true, 0, 389, 550, 389);
    	}
    However, since I used the startDrag script but didn't end with a stopDrag script, I cannot do anything in my movie as it is still dragging. So I thought of changing it to the following:

    Code:
    onClipEvent (enterFrame) {
    	startDrag(getProperty(_x, _y), true, 0, 389, 550, 389);
            if (_x <= 379) {
                   stopDrag ()
           }
    }
    But now the arrow does not move but I can click on buttons and such. Can anyone please help me modify it so that it works but does not do anything to my other objects?

    Thanx a milliion!

  2. #2
    Senior Member bgroves's Avatar
    Join Date
    Dec 2000
    Location
    Los Gatos, CA
    Posts
    479
    Don't use drag. Use this instead:

    onClipEvent (enterFrame) {
    _x=_root._xmouse;
    _y=_root._ymouse;
    }



    B

  3. #3
    Member
    Join Date
    Aug 2001
    Posts
    36
    Thanks alot, it works but how do I make it like your site's nav bar? In your site, when I move my mouse to a certain height, the nav bar returns back to one corner. Like your nav bar how do I make it so that when my mouse moves to a certain part of the movie, the arrow stops following? Oh yes, how do i make other smaller arrows follow the main mouse in a bouncing fashion like your signature?

    thnx again!

    [Edited by dud on 03-15-2002 at 07:30 PM]

  4. #4
    Senior Member bgroves's Avatar
    Join Date
    Dec 2000
    Location
    Los Gatos, CA
    Posts
    479
    This is how my nav bar is set up:


    onClipEvent (enterFrame) {
    if (_root._ymouse>=425) {
    tx=400;
    ty=450;
    } else {
    tx=-150;
    ty=475;
    }
    _x=_x-.25*(_x-tx);
    _y=_y-.25*(_y-ty);
    }


    The rest is triggered by buttons.

    How do you mean 'bouncing'? You mean motion trails? (cuz that's what my sig is doin').

    B

  5. #5
    Member
    Join Date
    Aug 2001
    Posts
    36
    I dont really know whats all that...i'm just beginning to learn AS.

    When i say bouncing i mean like when i move the mouse to one side, the rest follow in but bounce from left to right abit...like boing...boing...

    THANX!!!!

  6. #6
    Senior Member bgroves's Avatar
    Join Date
    Dec 2000
    Location
    Los Gatos, CA
    Posts
    479
    You kinda lost me....what is it that bounces from left to right? You mean the way the letters move <of brealdesign>?

    As for the code, you want me to explain?


    B

  7. #7
    Member
    Join Date
    Aug 2001
    Posts
    36
    Nevermind about the bouncing part 1st. but can you please explain the code to me? roguhly i know hwta it means but I wanna know what it does. THNX A MIL!!!!

  8. #8
    Senior Member bgroves's Avatar
    Join Date
    Dec 2000
    Location
    Los Gatos, CA
    Posts
    479
    You put this code in the MC (right-click on the MC and select "Actions").


    onClipEvent (enterFrame) {
    if (_root._ymouse>=425) {
    tx=400;
    ty=450;
    } else {
    tx=-150;
    ty=475;
    }
    _x=_x-.25*(_x-tx);
    _y=_y-.25*(_y-ty);
    }

    It means, it the y position of the mouse is greater than 425, tx and ty get values, otherwise other values. Those values are then used next -- x position gets x position minus 25% of the difference between x position and tx. It gives it that variable speed, because it moves 25% of the distance remaining (tx and ty are the destination positions). Make sense?

    B

  9. #9
    Member
    Join Date
    Aug 2001
    Posts
    36
    yes....thank you....

  10. #10
    Member
    Join Date
    Aug 2001
    Posts
    36
    it stil doenst work.

    goto http://portfolio.10der.org/main.htm and see the nav bar. when you move your mouse in between the words, the green and grey MC follows the mouse, if you move your mouse away from the words, it stops following.

    How do I do that?

  11. #11
    Senior Member bgroves's Avatar
    Join Date
    Dec 2000
    Location
    Los Gatos, CA
    Posts
    479
    All you need to do is change the parameters a bit.


    onClipEvent (load) {
    initx = _x;
    }
    onClipEvent (enterFrame) {
    if (_root._ymouse>=325 && _root._ymouse<=341 && _root._xmouse<=275) {
    tx = _root._xmouse;
    } else {
    tx = initx;
    }
    _x = _x-.25*(_x-tx);
    }



    B

  12. #12
    Member
    Join Date
    Aug 2001
    Posts
    36
    How do i make a MC such that its like a trailing thingy, like your signature, the back follows the front...

    THNX!!!!!!
    [Edited by dud on 03-19-2002 at 01:52 AM]

  13. #13
    Senior Member bgroves's Avatar
    Join Date
    Dec 2000
    Location
    Los Gatos, CA
    Posts
    479
    Make two clips, both of which look the same (in my case, two white circles). One is the 'head', the other 'tail'. Give the head code that handles motion, and duplicating the tail, give the tail code/animation of fading/scaling down. Them's the basics.

    B

  14. #14
    Member
    Join Date
    Aug 2001
    Posts
    36
    what code?

  15. #15
    Senior Member bgroves's Avatar
    Join Date
    Dec 2000
    Location
    Los Gatos, CA
    Posts
    479
    Here's an easy example:

    onClipEvent(load){
    destx=random(550);
    desty=random(400);
    i=1;
    }

    onClipEvent(enterFrame){
    _x+=.25*(destx-_x);
    _y+=.25*(desty-_y);
    if(_x>.99*destx){
    destx=random(550);
    desty=random(400);
    }
    _root.tail.duplicateMovieClip("tail"+i,i);
    _root["tail"+i]._x=_x;
    _root["tail"+i]._y=_y;
    i++;
    }

    Then add a removeClip(this), at the end of the 'tail's animation, and make sure it starts off screen.

    B

  16. #16
    Member
    Join Date
    Aug 2001
    Posts
    36
    I dont really understand but nevermind.

    thnx for all your help!!

  17. #17

  18. #18
    Member
    Join Date
    Aug 2001
    Posts
    36
    thank you, it works now, but if i put the trail there, my tail MC will appear at the top left corner of my Movie.


    why is that so?

    [Edited by dud on 03-20-2002 at 02:24 AM]

  19. #19
    Senior Member bgroves's Avatar
    Join Date
    Dec 2000
    Location
    Los Gatos, CA
    Posts
    479
    Are you embedding the mc's in another MC? 'put the trail there'? Need to know a little more re: the structure of you flash (i think).

    B

  20. #20
    Member
    Join Date
    Aug 2001
    Posts
    36
    well, you know the script you gave me for the nav bar, the one which starts with 'onClipEvent(enterFrame){ initx = _x;' i put the trailing code after that code, so I have two codes on one MC. Now when I play my movie, the trailing MC (tail) appears at the top right hand side of my movie... how to remove? I think it has to do with the _x and the _y

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