Quantcast
Viewing all articles
Browse latest Browse all 37

Flash tutorial: creating a simple button with Flash ActionScript 3.0

Image may be NSFW.
Clik here to view.
Share

Today : How to create a simple button in Flash with AS3.

Example

-->

Image may be NSFW.
Clik here to view.
Get Adobe Flash player

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

  1. Open Flash > Create a new Flash ActionScript 3.0 document
  2. Insert > New Symbol
  3. Name : Btn
  4. Type > Button
  5. Click OK

Image may be NSFW.
Clik here to view.
Capture d’écran 2013-09-28 à 16.10.09

  1. Draw a button in the Up state (when the button is released)
  2. Draw a different button in the Over  state (when the mouse cursor is over the button)
  3. Daw a different button in the Down state (when the button is pressed)
  4. Draw a simple shape in the Hit state (The Hit area of the button)
  5. It’s done. Back to the stage now.

Image may be NSFW.
Clik here to view.
Capture d’écran 2013-09-28 à 16.18.25

  1. Then select the MovieClip on the stage
  2. Set an instance name “mc_btn” in the Properties pannel like this

Image may be NSFW.
Clik here to view.
simple_button_02

  1. Create a new Layer with this name: Actions
  2. Select this new layer
  3. Open the Actions Pannel: Windows > Actions or hit F9

Image may be NSFW.
Clik here to view.
simple_button_03

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.


Viewing all articles
Browse latest Browse all 37

Trending Articles