Question
CS3 Event Handlers
I have a MovieClip that I am using as a button (which was
previously possible in Flash 8). I created the up, over, and down
frames in the button and am writing the AS3 code for the button. It
looks like this:
import flash.events.MouseEvent;
function playMovie(event:MouseEvent):void
{
clip1.play();
}
function overState(event:MouseEvent):void {
playButton.gotoAndStop(5);
}
function downState(event:MouseEvent):void {
playButton.gotoAndStop(10);
}
function outState(event:MouseEvent):void {
playButton.gotoAndStop(1);
}
playButton.addEventListener(MouseEvent.CLICK, playMovie);
playButton.addEventListener(MouseEvent.MOUSE_OVER, overState);
playButton.addEventListener(MouseEvent.MOUSE_DOWN, downState);
playButton.addEventListener(MouseEvent.MOUSE_OUT, outState);
That's an awful lot of code for 1 button. If I had 5 or 6 buttons, that's a lot to edit. Is there an easier way to do this?
import flash.events.MouseEvent;
function playMovie(event:MouseEvent):void
{
clip1.play();
}
function overState(event:MouseEvent):void {
playButton.gotoAndStop(5);
}
function downState(event:MouseEvent):void {
playButton.gotoAndStop(10);
}
function outState(event:MouseEvent):void {
playButton.gotoAndStop(1);
}
playButton.addEventListener(MouseEvent.CLICK, playMovie);
playButton.addEventListener(MouseEvent.MOUSE_OVER, overState);
playButton.addEventListener(MouseEvent.MOUSE_DOWN, downState);
playButton.addEventListener(MouseEvent.MOUSE_OUT, outState);
That's an awful lot of code for 1 button. If I had 5 or 6 buttons, that's a lot to edit. Is there an easier way to do this?