Copy link to clipboard
Copied
I have a simple movie clip on stage, (has its own timeline). I need a button on stage, (onHover) to play frame 2 of the MC and (onRollout) to play fram 16 of the mc?
both mc and button are on stage, timeline is one frame.
Hi.
It could be something like this:
import flash.events.MouseEvent;
function startAnim(e:MouseEvent):void
{
yourAnim.gotoAndPlay(2);
}
function endAnim(e:MouseEvent):void
{
yourAnim.gotoAndPlay(16);
}
yourButton.addEventListener(MouseEvent.MOUSE_OVER, startAnim);
yourButton.addEventListener(MouseEvent.MOUSE_OUT, endAnim);
Just assign two mouse event listeners to your button: one for when the cursor is hovering over the button and another one for when the cursor is out.
If you want yo
...Copy link to clipboard
Copied
Hi.
It could be something like this:
import flash.events.MouseEvent;
function startAnim(e:MouseEvent):void
{
yourAnim.gotoAndPlay(2);
}
function endAnim(e:MouseEvent):void
{
yourAnim.gotoAndPlay(16);
}
yourButton.addEventListener(MouseEvent.MOUSE_OVER, startAnim);
yourButton.addEventListener(MouseEvent.MOUSE_OUT, endAnim);
Just assign two mouse event listeners to your button: one for when the cursor is hovering over the button and another one for when the cursor is out.
If you want your code to be more efficient, you can add and remove the mouse out event only when needed.
import flash.events.MouseEvent;
function startAnim(e:MouseEvent):void
{
yourAnim.gotoAndPlay(2);
yourButton.addEventListener(MouseEvent.MOUSE_OUT, endAnim);
}
function endAnim(e:MouseEvent):void
{
yourAnim.gotoAndPlay(16);
yourButton.removeEventListener(MouseEvent.MOUSE_OUT, endAnim);
}
yourButton.addEventListener(MouseEvent.MOUSE_OVER, startAnim);
Regards,
JC