Reputation: 265
So like the title says, I have an overly-simple button (code below) that I can't see any obvious reason why it wouldn't work. When the mouse is over the button, it should proceed to the "over" state, and when the mouse is off again it should display the "normal" stage. Nothing fancy, but any time I roll over the button, I receive both trace messages within a second of each other (without my cursor coming off of the button).
I've also tried MouseEvent.MOUSE_OVER
, MouseEvent.MOUSE_OUT
with the same results.
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class thisShouldWork extends MovieClip{
public function thisShouldWork() {
mouseChildren = false;
this.addEventListener(MouseEvent.ROLL_OVER, handleMouseRollOver, false, 0, true);
this.addEventListener(MouseEvent.ROLL_OUT, handleMouseRollOut, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_DOWN, handleMouseDown, false, 0, true);
}
protected function handleMouseRollOver(event:MouseEvent):void{
trace("OVER" + event.currentTarget);
gotoAndStop("over");
}
protected function handleMouseRollOut(event:MouseEvent):void{
trace("NORMAL");
gotoAndStop("normal");
}
protected function handleMouseDown(event:MouseEvent):void{
trace("DOWN");
gotoAndStop("down");
}
}
}
Upvotes: 0
Views: 97