Skip to main content
September 11, 2010
Answered

Simple Play Button Help

  • September 11, 2010
  • 1 reply
  • 1029 views

Hi, I'm really new to flash and I have just completed an animation.  I would like to add a play button at the beginning of the animation that plays the whole thing through.  My buttons name is playbutton_btn and all the animation starts on frame 2 (frame one is a blank frame in all layers but the actionscript on the button.)  here is the code I have so far (in the first frame of the animation.

stop();
playbutton_btn.addEventListener(MouseEvent.CLICK, playit);
function playit(event:MouseEvent):void {
    gotoAndPlay(2);
}

This is in the hope that it will stop when played and prompt the viewer with the play button screen and when clicked play the animation through to the finish.

I get the error:

1120: Access of undefined property playbutton_btn.

If anyone could give me a hand or point me in the right direction that would be great:).

Cheers.

This topic has been closed for replies.
Correct answer Ned Murphy

The code uses "playbutton_btn" as the instance name for the button.  Did you assign that name to the button in the properties panel (where it says <Instance Name>)

1 reply

Ned Murphy
Legend
September 11, 2010

The code is fine.  Is the button also in frame 1, and is it assigned the instance name the code uses?

September 11, 2010

Yep the button is dead centre in the middle of the screen on frame 1.  What do you mean by assigned the instance the code uses?