Solved

Mouse activated scrolling navigation in Flash MX

Posted on 2006-07-13
2
195 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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
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 what frame rate is, how to control it and what effect it has on the video.

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now