ActionScript Reference

com.bjc.ccs1

class BJCSwitch

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



class BJCSwitch
extends UIComponent

The BJC Switch is a control component that allows users to set values by switching the states of the component. The BJC Switch component has two modes: 'On/Off' and 'Regular'. The On/Off mode has two states and the Regular mode has three states. The user defined callback function will be called with value '1' if the component state is set to 'Up'. The 'Middle' state executes the callback function with the value '2' and the 'Down' state with the value '3'. The Middle state is only available when the Regular mode is on.

Usage:
myBJCSwitch.setCallback( "myCallback" ); // Set the function to call on state change
 
function myCallback( value )
{
	if( value == 1 )
	{
		trace( "SWITCH UP" ); // This code will run on up state
	}
	else if( value == 2 )
	{
		trace( "SWITCH MIDDLE" ); // This code will run on middle state
	}
	else if( value == 3 )
	{
		trace( "SWITCH DOWN" ); // This code will run on down 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 switch state has changed.

public
Mode: String (write-only)
This property may be used to set the switch 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
TitleDown: String (write-only)
This property may be used to set the title of the down state.

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

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

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


BJCSwitch ( )
Constructor

Method Summary

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

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

public
setCallback ( cb: String ): Void
This method may be used to set the function to be called when the switch state has changed.

public
setDown ( ): Void
This method may be used to set the switch state to 'Down'.

public
setMiddle ( ): Void
This method may be used to set the switch state to 'Middle'.

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

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

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



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 switch state has changed.

Mode

public Mode: String (write-only)
This property may be used to set the switch 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.

TitleDown

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

TitleFont

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

TitleMiddle

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

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

BJCSwitch

function BJCSwitch()
Constructor


Method Documentation

getValue

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

Usage:
myVar = myBJCSwitch.getValue();

Returns:
The current state of the switch. Returns '1' when the switch state is 'Up'. Returns '2' when the switch state is 'Middle' and '3' when the switch state is 'Down'.

setBgColor

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

Usage:
myBJCSwitch.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 switch state has changed.

This method may be used to set the function to be called when the switch state has changed. The called function must be in the same timeline as the component or the path to the function must be specified as well.

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

Parameters:
cb
The function to be called when the switch state has changed.
Returns:
Nothing.

setDown

public function setDown(): Void
This method may be used to set the switch state to 'Down'.

Usage:
myBJCSwitch.setDown();

Returns:
Nothing.

setMiddle

public function setMiddle(): Void
This method may be used to set the switch state to 'Middle'.

Usage:
myBJCSwitch.setMiddle();

Returns:
Nothing.

setMode

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

This method may be used to set mode of the switch. The On/Off mode has two states: 'Up' and 'Down'. The Regular mode has also a 'Middle' state.

Usage:
myBJCSwitch.setMode( "Regular" );

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

setTitles

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

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

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 'Down' state. May be set to null to disable this change.
text3
A string value that indicates the title of the 'Middle' state. May be set to null to disable this change.
Returns:
Nothing.

setUp

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

Usage:
myBJCSwitch.setUp();

Returns:
Nothing.