Image may be NSFW.
Clik here to view.
Today : How to create a simple button in Flash with AS3.
Example
Image may be NSFW.
Clik here to view.
Sources
You can find the .fla and with the ActionScript source code inside.
Download the source code here: Simple_button_benoitfreslon.com.fla
Let’s start
- Open Flash > Create a new Flash ActionScript 3.0 document
- Insert > New Symbol
- Name : Btn
- Type > Button
- Click OK
Image may be NSFW.
Clik here to view.
- Draw a button in the Up state (when the button is released)
- Draw a different button in the Over state (when the mouse cursor is over the button)
- Daw a different button in the Down state (when the button is pressed)
- Draw a simple shape in the Hit state (The Hit area of the button)
- It’s done. Back to the stage now.
Image may be NSFW.
Clik here to view.
- Then select the MovieClip on the stage
- Set an instance name “mc_btn” in the Properties pannel like this
Image may be NSFW.
Clik here to view.
- Create a new Layer with this name: Actions
- Select this new layer
- Open the Actions Pannel: Windows > Actions or hit F9
Image may be NSFW.
Clik here to view.
Copy and paste this code:
mc_btn.addEventListener(MouseEvent.CLICK, click); function click(e:MouseEvent):void { // On click trace("click"); navigateToURL(new URLRequest("http://www.benoitfreslon.com")); }
The post Flash tutorial: creating a simple button with Flash ActionScript 3.0 appeared first on Benoît Freslon's Blog - Indie Game Designer.