PDA

View Full Version : actionscript-detect rollout?


sheepy
08-11-2001, 08:05 AM
I have created animated buttons that, on mouseover, animate open and on rollout, animate closed. The button is a movie clip with the animations nested as movieclips inside it with invisible buttons using onmouseevents to respond to the mouse. HOWEVER, sometimes if the user moves the mouse over the button too quickly, it seems it only picks up the "mouseover" action, and misses the "rollout", hence, the button is left hanging open.I don't have a massive amount of experience of actionscript, butI thought there might be a script that could be attached to the symbol, so it would update and know if the mouse was not on it? Would it be an if,else kind of thing? Any help would be really appreciated.

zekebru
08-13-2001, 01:29 PM
Instead of using invisible buttons, you can use the hitTest() function to check to see if the mouse is over the movie clip. the following code would be a way to do this. It goes inside the actions for each movie clip instance.

onClipEvent(enterFrame){
if (this.hitTest(_root._xmouse, _root._ymouse, false)) {
_root.hit = true;
_root.activeLink = this
}else{
_root.hit = false;
}
}

To explain the code . . . the onClipEvent fires regularly, in time with the framerate of your movie. this.hitTest() checks to see if the mouse is within the movielip that contains the code. Then, you can do whatever you want within the code.

I hope that helps,