ActionScript Reference

com.bjc.ccs1

class BJCButton

mx.core.UIComponent
  |
  +--com.bjc.ccs1.BJCButton



class BJCButton
extends UIComponent

The BJC Button is a control component that allows users to set values by clicking the component. The BJC Button component has two modes: 'On/Off' and 'Regular'. The user defined callback function will be called with value '1' if the component mode is set to 'Regular' or if the button state is set to 'Up'. The 'Pressed' state executes the callback function with the value '2'.

Usage:
myBJCButton.setCallback( "myCallback" ); // Set the function to call on click
 
function myCallback( value )
{
	if( value == 1 )
	{
		trace( "BUTTON UP" ); // This code will run on up state
	}
	else if( value == 2 )
	{
		trace( "BUTTON DOWN" ); // This code will run on pressed state
	}
}


Author:
Flashloaded - www.flashloaded.com

Version:
1.5.0


Property Summary

public
BgColor: Number (write-only)
This property may be used to set the background color.

public
CallBackFunction: String (write-only)
This property may be used to set the function to be called when the button has been clicked.

public
Mode: String (write-only)
This property may be used to set the button mode.

public
Start: String (write-only)
This property may be used to set the state on start.

public
TitleColor: Number (write-only)
This property may be used to set the font color.

public
TitleFont: String (write-only)
This property may be used to set the text font.

public
TitlePressed: String (write-only)
This property may be used to set the title of the pressed state.

public
TitleReg: String (write-only)
This property may be used to set the title of the regular mode.

public
TitlesVisible: String (write-only)
This property may be used to set the title visibility.

public
TitleUp: String (write-only)
This property may be used to set the title of the up state.

Constructor


BJCButton ( )
Constructor

Method Summary

public
getValue ( ): Number
This method may be used to get the current state value of the button.

public
setBgColor ( col: Number ): Void
This method may be used to set the background color of the button.

public
setCallback ( cb: String ): Void
This method may be used to set the function to be called when the button is pressed.

public
setMode ( mode: String ): Void
This method may be used to set mode of the button.

public
setOff ( ): Void
This method may be used to set the button state to 'Up'.

public
setOn ( ): Void
This method may be used to set the button state to 'Pressed'.

public
setTitles ( view: Boolean, font: String, color: Number, text1: String, text2: String ): Void
This method may be used to set the visibility of the title field and changes the title texts.



Property Documentation

BgColor

public BgColor: Number (write-only)
This property may be used to set the background color.

CallBackFunction

public CallBackFunction: String (write-only)
This property may be used to set the function to be called when the button has been clicked.

Mode

public Mode: String (write-only)
This property may be used to set the button mode.

Start

public Start: String (write-only)
This property may be used to set the state on start.

TitleColor

public TitleColor: Number (write-only)
This property may be used to set the font color.

TitleFont

public TitleFont: String (write-only)
This property may be used to set the text font.

TitlePressed

public TitlePressed: String (write-only)
This property may be used to set the title of the pressed state.

TitleReg

public TitleReg: String (write-only)
This property may be used to set the title of the regular mode.

TitlesVisible

public TitlesVisible: String (write-only)
This property may be used to set the title visibility.

TitleUp

public TitleUp: String (write-only)
This property may be used to set the title of the up state.


Constructor Documentation

BJCButton

function BJCButton()
Constructor


Method Documentation

getValue

public function getValue(): Number
This method may be used to get the current state value of the button.

Usage:
myVar = myBJCButton.getValue();

Returns:
The current state of the button. Returns '1' when the button mode is regular or when the button state is 'Up'. Returns '2' when the button state is 'Pressed'.

setBgColor

public function setBgColor(col: Number): Void
This method may be used to set the background color of the button.

Usage:
myBJCButton.setBgColor( 0xff0000 );

Parameters:
col
A color value that indicates the background color of the component.
Returns:
Nothing.

setCallback

public function setCallback(cb: String): Void
This method may be used to set the function to be called when the button is pressed.

This method may be used to set the function to be called when the button is pressed. The called function must be in the same timeline as the component or the path to the function must be specified as well.

Usage:
myBJCButton.setCallback( "_root.cbFunc" );

Parameters:
cb
The function to be called when the button is pressed.
Returns:
Nothing.

setMode

public function setMode(mode: String): Void
This method may be used to set mode of the button.

This method may be used to set mode of the button. The On/Off mode has two states: 'Up' and 'Pressed'. The Regular mode has only one state.

Usage:
myBJCButton.setMode( "Regular" );

Parameters:
mode
The mode of the button to be set. The mode can be either 'On/Off' or 'Regular'.
Returns:
Nothing.

setOff

public function setOff(): Void
This method may be used to set the button state to 'Up'.

Usage:
myBJCButton.setOff();

Returns:
Nothing.

setOn

public function setOn(): Void
This method may be used to set the button state to 'Pressed'.

Usage:
myBJCButton.setOn();

Returns:
Nothing.

setTitles

public function setTitles(view: Boolean,
font: String,
color: Number,
text1: String,
text2: String): Void
This method may be used to set the visibility of the title field and changes the title texts.

Usage:
myBJCButton.setTitles( true, "Arial", 0xff0000, "Stop", null );

Parameters:
view
A boolean value that indicates the visibility of the title field.
font
The font name that will be used in the title field. May be set to null to disable this change.
color
A color value that indicates the font color of the title field. May be set to null to disable this change.
text1
A string value that indicates the title of the 'Up' state. May be set to null to disable this change.
text2
A string value that indicates the title of the 'Pressed' state. May be set to null to disable this change
Returns:
Nothing.