Skip to main content
Sep 11, 2010 7:29 AM UTC
Answered

Simple Play Button Help

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 is closed to new replies. Start a new post to keep the conversation going.
Ned Murphy
Ned MurphyCorrect answer
Legend
Sep 11, 2010 12:39 PM UTC

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>)

10 replies

Ned Murphy
Legend
Sep 11, 2010 12:05 PM UTC

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

Translate
Sep 11, 2010 12:29 PM UTC

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?

Translate