Josh Time | Joshua Li

Jul/10

9

jButton – A simple ActionScript 3 button class

In May 2010, I started programming in ActionScript 3 using FlashDevelop, a free and open source code editor.

Currently, the last update is from July 9th, 2010.

Since I like to have total control on the code I use, I have created my own class for making buttons in ActionScript 3. This class is just pure ActionScript 3.

The jButton features effects when the mouse interacts with it. When the mouse is hovered over the button, the alpha changes from 0.8 to 1.0. When the mouse hovers off, the alpha changes back to 0.8. Also, when the mouse button is held down on the button, the button moves down 2 pixels and moves back up when the mouse button is released. Lastly, this code is released into the public domain meaning that anyone can use, modify, sell, or do anything with this code freely.

To use the jButton class, just simply use the code:

new jButton("Button Label");

Only the first parameter is needed to use jButton. The first parameter is the label and is a String.

jButton can be configured more through the constructor. Below is a list of all the possible parameters:

jButton(label:String, color:int = 0xbbddff, width:int = 200, font:String = "Helvetica", fontSize:Number = 24, fontColor:int = 0x333333)

To change the label of the button, use the function setLabel(). The setLabel function accepts one parameter which is a String. An example is below.

var button:jButton = new jButton("Old Text");
button.setLabel("New Text");

Lastly, to import it, use (below the package

import com.joshtime.jButton;

Download the code below.
jButton version July 9th 2010

· · · · ·

No comments yet.

Leave a Reply

<<

>>

Theme Design by devolux.nh2.me