Solved

Mouse activated scrolling navigation in Flash MX

Posted on 2006-07-13
2
217 Views
Last Modified: 2008-03-04
Hello,

I’m trying to create a vertical navigation bar that scrolls back and forth along the y axis in response to the movement of the mouse.  There is a catch, however… It can only scroll when the mouse is over the navigation.  I have other objects elsewhere on the stage that respond to mouse movements and I’ve found that it can be quite distracting to have the navigation scrolling while I navigate other parts of the stage.  


Here’s the script which is applied to the navigation mc:

onClipEvent (load)
{
   ycenter=175;
   speed=1/20;
}
onClipEvent (enterFrame)
{
   var distance=_root._ymouse-ycenter;
   _y-=(distance*speed);
   if (_y > 0) _y=-513;
   if (_y < -513) _y=0;
}

My question is, how should I modify this code so that the navigation only scrolls while the mouse is over it.

Expert assistance is always appreciated.

Thanks
0
Comment
Question by:mileHighBlogger
  • 2
2 Comments
 
LVL 23

Accepted Solution

by:
Zeffer earned 400 total points
ID: 17104943
make the scrolling conditional on the mouse touching the movieclip..

onClipEvent (enterFrame){
      if (hitTest( _root._xmouse, _root._ymouse, false)){
      var distance=_root._ymouse-ycenter;
   _y-=(distance*speed);
   if (_y > 0) _y=-513;
   if (_y < -513) _y=0;
      }
}

Z
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 17104968
and of course you could do it with a function as well..

onClipEvent (enterFrame){
this.onRollOver = function () {
var distance=_root._ymouse-ycenter;
   _y-=(distance*speed);
   if (_y > 0) _y=-513;
   if (_y < -513) _y=0;
     }
}

Z
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question