Solved

Mouse activated scrolling navigation in Flash MX

Posted on 2006-07-13
2
223 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

809 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