Today : How to create a simple button in Flash with AS3.
Example
[swf:/wp-content/uploads/2013/09/Simple_button_benoitfreslon.com_.swf 400 300]
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
- 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.
- Then select the MovieClip on the stage
- Set an instance name “mc_btn” in the Properties pannel like this
- Create a new Layer with this name: Actions
- Select this new layer
- Open the Actions Pannel: Windows > Actions or hit F9
Copy and paste this code:
mc_btn.addEventListener(MouseEvent.CLICK, click); function click(e:MouseEvent):void { // On click trace("click"); navigateToURL(new URLRequest("https://www.benoitfreslon.com")); }