weavermedia
01-13-2009, 03:37 PM
I'm trying to find the best and most robust way of detecting a mouse over event on a button. I have an animation within the button mc that animates to the rollover state. I want to use prevFrame() to return back to the rollout state.
This code works fine when I mouse over slowly and let the animation play to each stop point, but if I mouse past the button quickly the rollover animation sticks and so does the nested looping animation within the button shape (a cheeky looping glint over the button to catch the eye). The SWF itself isn't breaking because the click handler is still working and opens the PNG when the button is clicked. Please help! Deadline looming!
stop();
butt.stop();
useHandCursor = true;
buttonMode = true;
addEventListener(MouseEvent.CLICK, buttCLICK);
addEventListener(MouseEvent.ROLL_OVER, rolledOver);
addEventListener(MouseEvent.ROLL_OUT, rolledOut);
function buttCLICK (e:MouseEvent):void
{
navigateToURL(new URLRequest("file:///C:/test.png"));
}
function rolledOver (e:MouseEvent):void
{
addEventListener(Event.ENTER_FRAME, doRollOver);
}
function rolledOut (e:MouseEvent):void
{
addEventListener(Event.ENTER_FRAME, doRollOut);
}
function doRollOver(e:Event)
{
butt.nextFrame();
if (butt.currentFrame==9){
butt.gotoAndStop(9);
removeEventListener(Event.ENTER_FRAME, doRollOver);
}
}
function doRollOut(e:Event)
{
butt.prevFrame();
if (butt.currentFrame==1){
butt.gotoAndStop(1);
removeEventListener(Event.ENTER_FRAME, doRollOut);
}
}
This code works fine when I mouse over slowly and let the animation play to each stop point, but if I mouse past the button quickly the rollover animation sticks and so does the nested looping animation within the button shape (a cheeky looping glint over the button to catch the eye). The SWF itself isn't breaking because the click handler is still working and opens the PNG when the button is clicked. Please help! Deadline looming!
stop();
butt.stop();
useHandCursor = true;
buttonMode = true;
addEventListener(MouseEvent.CLICK, buttCLICK);
addEventListener(MouseEvent.ROLL_OVER, rolledOver);
addEventListener(MouseEvent.ROLL_OUT, rolledOut);
function buttCLICK (e:MouseEvent):void
{
navigateToURL(new URLRequest("file:///C:/test.png"));
}
function rolledOver (e:MouseEvent):void
{
addEventListener(Event.ENTER_FRAME, doRollOver);
}
function rolledOut (e:MouseEvent):void
{
addEventListener(Event.ENTER_FRAME, doRollOut);
}
function doRollOver(e:Event)
{
butt.nextFrame();
if (butt.currentFrame==9){
butt.gotoAndStop(9);
removeEventListener(Event.ENTER_FRAME, doRollOver);
}
}
function doRollOut(e:Event)
{
butt.prevFrame();
if (butt.currentFrame==1){
butt.gotoAndStop(1);
removeEventListener(Event.ENTER_FRAME, doRollOut);
}
}