CustomButton

Package:
Class:
Inheritance:
biz.flashscript.components.buttons
public class CustomButton
MovieClip
The CustomButton class is the base class for a custom Button component. The button can have label or image or both. To create an instance of the CustomButton component place an instance of the component on the main timeline or call the CustomButton class.
Public Properties
Property Defined By
image :String
Allows adding an image.
CustomButton
label :String
Defines the label for the button.
CustomButton
enabled :Boolean
If false the button will be disabled and the color changes.
CustomButton
bitmapAlpha :Number
Sets the alpha for the image.
CustomButton
Public Methods
Method Defined By
All inherited methods of the MovieClip class N/A
Events
Event Defined By
All inherited events for the MovieClip class. N/A
reloadImage(img:String):void
Allows changing to a different image.
CustomButton
Property Detail

image property
image:String [read-write]

This defines an image for the button.

Implementation

public function get image():String
public function set image(value:String):void

label property
label:String [read-write]

This defines the text value for the button.

The default value is Button.

Implementation

public function get label():String
public function set label(value:String):void

enabled property
enabled:String [read-write]

This disables the button with color change.

The default value is true.

Implementation

public function get enabled():Boolean
public function set enabled(value:Boolean):void

bitmapAlpha property
bitmapAlpha:Number [read-write]

This sets the alpha value of an incorporated image.

The default value is 1.

Implementation

public function get bitmapAlpha():Number
public function set bitmapAlpha(value:Number):void
Constructor Detail
CustomButton ()  Constructor
public function CustomButton()
To initialize an instance use new CustomButton().
Method Detail

reloadImage()  method
public function reloadImage(img:String):void

This method allows to change to a different image in the button.

Parameters

  • img:String ____ Specifies the image class.
Examples
Create a new fla file and name it CustomButtonExample.fla. Put the name CustomButtonExample in the class field. Place three CustomButtons on the timeline, name them butOne, butTwo and butThree. Place a textfield and name it myText. Save the file in the same folder where the biz folder is located. Create an actionscript file and name it CustomButtonExample.as. Put the script below in the as file.

package 
{
	import flash.display.Sprite;
	import biz.flashscript.components.buttons.CustomButton;
	import flash.text.TextField;
	import flash.events.MouseEvent;
	//
	public class CustomButtonExample extends Sprite
	{
		public var myText:TextField;
		public var butOne:CustomButton;
		public var butTwo:CustomButton;
		public var butThree:CustomButton;
		
		public function CustomButtonExample ():void
		{
			butOne.label = "Button One";
			butOne.image = "dot1";
			butOne.addEventListener(MouseEvent.CLICK, callHandler);
			
			butTwo.label = "Button Two";
			butTwo.image = "dot2";
			butTwo.addEventListener(MouseEvent.CLICK, callHandler);
			
			butThree.label = "Button Three";
			butThree.image = "dot3";
			butThree.addEventListener(MouseEvent.CLICK, callHandler);
		}
		private function callHandler (event:MouseEvent):void
		{
			var butLabel:String = event.currentTarget.label as String;
			myText.text = "This is "+butLabel+" !";
		}
	}
}
Get Adobe Flash player