View Full Version : Mouse speed
paisley
June 5th, 2003, 06:48 PM
Is there a way to know the speed of a mouse or how long a mouse is over a movieclip?
Coz i have a movieclip that if I rolled over it for a specific period of seconds, it shows a picture but if the movieclip was just passed over a second, it won't show the picture.
Need help badly
zylum
June 5th, 2003, 11:10 PM
you can add a timer and an if statement which checks if the mouse is over the movieclip. if it is then increment the timer. when the timer reaches a certain numbr then gotoAndPlay to the frame with the new pic. when the mouse leaves the movieclip then reset the timer to zero. does that help?
zylum
June 5th, 2003, 11:21 PM
put this script in the maintimeline
timer = 0;
amountOfTime = 48;
onEnterFrame = function () {
if (pic.hitTest(_xmouse, _ymouse, true)) {
timer++;
if (timer>amountOfTime) {
pic.gotoAndStop(2);
}
} else {
timer = 0;
pic.gotoAndStop(1)
}
};
pic refers to the MC you want to add the action to. when the mouse is over the movei clip, the the timer increments and checks whether it timer has reached 'amountOfTime' which is set as 48. this would be two seconds when using 24 fps. Once timer has reached the amountOfTime then pic goesToAnStops on the next frame which has a new image. then an else statement tells the pic to go back to the first frame and resets timer... hope that explains it all :)
zylum
ps, heres a fla if you need it
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.