ActionScript Reference

com.bjc.ccs1

class BJCJoystick

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



class BJCJoystick
extends UIComponent

The BJC Joystick is a control component that allows users to move objects on 2D axis or specify two values at the same time. The joystick calls it's callback function with two values. If the joystick mode is 'X, Y', the callback function will receive the values x-position and y-position of the joystick knob. If the joystick mode is 'Angle, Distance', the callback function will receive the values angle and distance of the joystick knob from center point.

Usage:
myBJCJoystick.setCallback( "myCallback" ); // Set the function to call on knob dragging
 
function myCallback( value1, value2 )
{
	trace( "VALUE1: " + value1 + "VALUE2: " + value2 ); 
	// This code will run when the joystick knob is dragged
}


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 joystick is moved.

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

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

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

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

public
TitleVisible: String (write-only)
This property may be used to hide or show the title field.

public
ValueVisible: String (write-only)
This property may be used to hide or show the value fields.

Constructor


BJCJoystick ( )
Constructor

Method Summary

public
getAngle ( ): Number
This method may be used to get the current direction angle of the joystick knob from center point.

public
getDistance ( ): Number
This method may be used to get the current distance of the joystick knob from center point.

public
getXValue ( ): Number
This method may be used to get the current X position of the joystick knob.

public
getYValue ( ): Number
This method may be used to get the current Y position of the joystick knob.

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

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

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

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

public
viewValues ( view: Boolean, font: String, color: Number ): Void
This method may be used to set the visibility of the value fields.



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 joystick is moved.

Font

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

FontColor

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

Mode

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

Title

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

TitleVisible

public TitleVisible: String (write-only)
This property may be used to hide or show the title field.

ValueVisible

public ValueVisible: String (write-only)
This property may be used to hide or show the value fields.


Constructor Documentation

BJCJoystick

function BJCJoystick()
Constructor


Method Documentation

getAngle

public function getAngle(): Number
This method may be used to get the current direction angle of the joystick knob from center point.

Usage:
myVar = myBJCJoystick.getAngle();

Returns:
The current knob direction angle from center point. Returns values between 0 and 360.

getDistance

public function getDistance(): Number
This method may be used to get the current distance of the joystick knob from center point.

Usage:
myVar = myBJCJoystick.getDistance();

Returns:
The current knob distance from center point. Returns values between 0 and 100.

getXValue

public function getXValue(): Number
This method may be used to get the current X position of the joystick knob.

Usage:
myVar = myBJCJoystick.getXValue();

Returns:
The current X position. Returns values between -100 and 100.

getYValue

public function getYValue(): Number
This method may be used to get the current Y position of the joystick knob.

Usage:
myVar = myBJCJoystick.getXValue();

Returns:
The current Y position. Returns values between -100 and 100.

setBgColor

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

Usage:
myBJCJoystick.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 joystick knob is dragged.

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

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

Parameters:
cb
The function to be called when the joystick knob is dragged.
Returns:
Nothing.

setMode

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

This method may be used to set mode of the joystick. The 'X/Y' mode will send values from -100 to 100 as the X-positon value and values from -100 to 100 as the Y-positon value to the callback function. The 'Angle/Distance' mode will send values from 0 to 360 as the angle value and values from 0 to 100 as distance value to the callback function.

Usage:
myBJCJoystick.setMode( "X/Y" );

Parameters:
mod
The mode of the joystick to be set. The mode can be either 'X/Y' or 'Angle/Distance'.
Returns:
Nothing.

setTitle

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

Usage:
myBJCJoystick.setTitle( true, "Arial", 0xff0000, "Direction" );

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

viewValues

public function viewValues(view: Boolean,
font: String,
color: Number): Void
This method may be used to set the visibility of the value fields.

Usage:
myBJCJoystick.viewValues( false, null, null );

Parameters:
view
A boolean value that indicates the visibility of the value fields.
font
The font name that will be used in the component. May be set to null to disable this change.
color
A color value that indicates the font color of the component. May be set to null to disable this change.
Returns:
Nothing.