This tutorial will show you how to use a button for navigation with AS3.
So first we must create a button. You can click Insert>New Symbol>Button and then draw your button inside of this new symbol. Or you can draw a button, highlight it and click Modify>Convert To Symbol>Button.
After you have created your button, you must give it an Instance Name.
I will give my button the instance name 'intro_btn' (Without the quotation marks)
Now open the actions panel for the frame that your button is on (Press F9). Paste the following script into your actions panel. (I have commented each part to give you a better
understanding of how it works):
// START OF SCRIPT
stop();
// The stop function stops the movie timeline on the current frame.
function onIntroClick(evt:MouseEvent):void {
gotoAndPlay(2);
}
// We have created a function. This is triggered when the End User clicks the button.
// This is followed by an Event, which is a Mouse Event.
// And because we aren't returning anything, we write void.
// Between our braces we tell the player what we want it to do. In this case we want to goto
// and play a frame. My intro is on frame 2, so i have typed 2.
intro_btn.addEventListener(MouseEvent.CLICK, onIntroClick);
// We have added an Event Listener, so that when we Click the intro_btn, the onIntroClick
// function is triggered.
// END OF SCRIPT
And that's a guide to creating buttons using Actionscript 3. To make multiple buttons just copy the script, but change the instance name and the function name for each button you use.