how to make a button go to a specific frame on the main timeline my button called a play_btn and i want it to go to a specific frame on the main timeline ???
+1
A:
put this code on frame 1 of your main timeline, in the same scene as the button.
play_btn.addEventListener(MouseEvent.CLICK, play_btnClickHandler);
function play_btnClickHandler(ev:MouseEvent):void
{
//The actual code to jump to a specific frame
this.gotoAndPlay(30);
}
30 being your frame number.
'this.' can be omitted, but I like it as it ensures its easier to understand what is being affected to those of whom are reading your code and may not be aware completely of what's going on.
Glycerine
2010-09-13 00:16:31
A:
it's often better to use a frame label in case the frame number changes following a modification in your animation.
play_btn.addEventListener(MouseEvent.CLICK, play_btnClickHandler); function play_btnClickHandler(ev:MouseEvent):void { //The actual code to jump to a specific frame this.gotoAndPlay('myFrameLabel'); }
PatrickS
2010-09-13 04:00:35