Copy link to clipboard
Copied
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.
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>)
Copy link to clipboard
Copied
The code is fine. Is the button also in frame 1, and is it assigned the instance name the code uses?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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>)
Copy link to clipboard
Copied
Ah I found where you mean, you where right, I had'nt changed the instance name. Works fine now:). Thanks for your help.
Copy link to clipboard
Copied
You're welcome
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
please help me
regards
leo
Copy link to clipboard
Copied
it gets this error
Scene 1, Layer 'action_green', Frame 1, Line 7, Column 10 1021: Duplicate function definition.
Copy link to clipboard
Copied
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more