Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Simple Play Button Help

Guest
Sep 11, 2010 Sep 11, 2010

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.

TOPICS
ActionScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 11, 2010 Sep 11, 2010

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

Translate
LEGEND ,
Sep 11, 2010 Sep 11, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 11, 2010 Sep 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 11, 2010 Sep 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 11, 2010 Sep 11, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 11, 2010 Sep 11, 2010

Ah I found where you mean, you where right, I had'nt changed the instance name.  Works fine now:).  Thanks for your help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 11, 2010 Sep 11, 2010

You're welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 11, 2010 Sep 11, 2010

Since the error you are getting isn't the error I would expect for what I am having you check anyways, I have a suspiscion that you need to go into your Flash Publish Settings and be sure to select AS3 as the actionscript version.  I suspect it is not currently so.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 13, 2024 Mar 13, 2024

hello Murphy very cool tip

how to a make the action script code for more thant one button in the same actions layer

how do i make more statements in the same action layer

leo240861267932_0-1710333955786.png  

please help me

regards 

leo

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 13, 2024 Mar 13, 2024

it gets this error

Scene 1, Layer 'action_green', Frame 1, Line 7, Column 10 1021: Duplicate function definition.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2024 Mar 13, 2024
LATEST

@leo240861267932 

 

this is from 2010 and ned is long gone to maine tending his apple (tree) orchard.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines