A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: PLEASE HELP Re: on mouse over stop

Hybrid View

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

    PLEASE HELP Re: on mouse over stop

    PLEASE HELP ME ...I made a personal site...but I dont know how to make it stop moving when the mouse pointer points to a certain button....I want it to stop moving when its on mouse over...what's the code to write? please help...to view the site I made...please go to.. www.theparadigm.tk

    I just used the code I got from kirupa.com which was

    onClipEvent (load)
    {
    xcenter=724;
    speed=1/50;
    }

    onClipEvent (enterFrame)
    {
    var distance=_root._xmouse-xcenter;
    _x+=(distance*speed);
    if (_x > 0) _x=-1448;
    if (_x < -1448) _x=0;
    }

    but it wont stop when my cursor is on a certain button...how should I stop it from moving when my cursor is on a certain button? please help...thanks...

    also, I wanted it to move to the left at the same pace as it moves to the right...how should I do that? please help..thanks in advance..

  2. #2
    Senior Member Dricciotti's Avatar
    Join Date
    Aug 2002
    Posts
    2,988
    Code:
    var rolledOver = false;
    /* What ever code you used to determine the rollOver. I 
    am just going to use this though */
    someButton.onRollOver = function()
    {
      //do something
      rolledOver = true;
    }
    someButton.onRollOut = function()
    {
      //do something
      rolledOver = false;
    }
    
    onClipEvent (enterFrame)
    {
      if(!rolledOver){
    var distance=_root._xmouse-xcenter;
    _x+=(distance*speed);
    if (_x > 0) _x=-1448;
    if (_x < -1448) _x=0;
    }
    }
    So we are using a variable to say whether a button is rolled over. If it is, then we dont allow that tweening motion in the onEnterFrame function to happen. If nothing is rolled over, we allow it to.

    Hope that helps

  3. #3
    Senior Member Dricciotti's Avatar
    Join Date
    Aug 2002
    Posts
    2,988
    Ok. Here is a better description of what to do:

    You have buttons throughout your movie and you want the scrolling to stop when you roll over one. Right? So, first you need to determine when you are rolling over a button. To do this, we need to add code to each button that detects if that button is being rolled over. What you would do is in the actions for a button, add this code:
    Code:
    on(rollOver){
      _root.rolledOver = true;
    }
    on(rollOut){
      _root.rollOver = false;
    }
    What this does is whenever you roll over the button, the variable "rolledOver" is true. Then, when the mouse leaves the button again (rolls out), the variable "rolledOver" is set to false again.

    Now we can use "rolledOver" to tell us whether any of the buttons are being rolled over, and therefor, whether or not we should stop the background from moving. Next, we need to edit the code that moves the background.
    Code:
    onClipEvent (enterFrame)
    {
    if(_root.rolledOver == false){
    var distance=_root._xmouse-xcenter;
    _x+=(distance*speed);
    if (_x > 0) _x=-1448;
    if (_x < -1448) _x=0;
    }
    }
    What the if statement does is say that if the variable "rolledOver" is false (and no buttons are being rolled over) then do the code that moves the background. But if it is true, then dont do anything.

    One final thing to add is you need to preset the value of "rolledOver" to false in order to make sure the backrground is scrolling when the movie begins. Simply put _root.rolledOver=false in the first frame of the main timeline.

    That should be it. Good luck. Post back with your progess.

  4. #4
    Junior Member
    Join Date
    May 2005
    Posts
    8
    i can now understand the code you typed but it doesn't work ...it still wont stop...when I made this .fla file, I had a hard time tracing the buttons..i tried for so many times to trace the button and the code w/c made it work when clicked was this (button name is resume):

    _level0.wholemovie.instance1.resume.onPress=functi on(){
    getURL("resume.php", "_self");
    }

    i've put those codes on the main timeline, first frame. so now, i tried to copy and paste your code to each button but it wont work...i also tried putting _level0.wholemovie. infront of each rollOver but still it wont work... what's the problem now?

  5. #5
    Junior Member
    Join Date
    May 2005
    Posts
    8
    bump

  6. #6
    Senior Member Dricciotti's Avatar
    Join Date
    Aug 2002
    Posts
    2,988
    Originally posted by khawen
    i can now understand the code you typed but it doesn't work ...it still wont stop...
    Ok. im not sure what your asking... what wont stop? Also, what is this PHP stuff?

    One problem I would guess your having is that your not refrencing something correctly. Try using the trace() function to check that. You can do something like: trace(_level0.wholemovie.instance1.resume._x). If you get a number, your refrencing it correctly, if not, you made a mistake somewhere there then.

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