Package | com.eqsim.components |
Class | public class AlphaNumDigits |
Inheritance | AlphaNumDigits ![]() |
This class subsumes the behavior of NumDigits to allow alphanumeric characters. In its "auto" mode, it has two possible behaviors: first, if the
value is numeric (positive or negative floating-point number), it does the same as NumDigits
. Second, if the value
is a string, it outputs it using alphanumeric characters.
As opposed to "auto" mode, the mode
property can also be set
to text
or number
to force the component to that type.
This components adds the option to left justify the alphanumeric string (this only works in text mode, or in auto mode when the value is not a number). Padding the left of a number with zeroes only works when the value is a number.
All English letters are represented, but a few non-alphanumeric characters (punctuation) are provided. To extend
this component with other character sets, or with characters not provided, open and modify the defDigXGfx
MovieClip, and see the explanation for the extendedCharactersFunction
property (which can only be set programmatically).
Users can change the appearance by creating a MovieClip that has a background, decimal point, and digits graphics, exactly
like defDigXPlusBkgnd. Set the property digSkinClassName
to the class name.
The class has one event -- "onOverflow", indicating value has overflowed the display. This occurs on positive and negative values that do not fit in the display window, as well as strings that don't fit. The value is returned in the event's value. If overflow occurs, the display is set to a line of 8s.
Property | Defined By | ||
---|---|---|---|
decimalPlaces : int
Number of decimal places to the right of the decimal point. | AlphaNumDigits | ||
digSkinClassName : String
The digSkinClassName lets you change the appearance of the alphanumeric display by using your own
class based on MovieClip, with a structure paralleling the default class, defDigXPlusBkgnd. | AlphaNumDigits | ||
digTint : int
Color (int) of each digit, for example, 0xFF0000 is pure red. | AlphaNumDigits | ||
display : Boolean
Whether or not to display the digit value. | AlphaNumDigits | ||
evtOverflow : String = onOverflow
Event name for event generated if the value of the display exceeds the
number of positions. | AlphaNumDigits | ||
extendedCharactersFunction : Function
The default character set does not implement the full set of possible characters -- just alphanumeric. | AlphaNumDigits | ||
leadZero : Boolean
Boolean property true or false, whether or not to pad left of decimal point with zeroes. | AlphaNumDigits | ||
leftJust : Boolean
If true, the alphanumeric string is left justified, otherwise (default) it is right justified. | AlphaNumDigits | ||
mode : String
The 'mode' property can tell the component to render the value in a specific way: auto, number, or text. | AlphaNumDigits | ||
numDigs : int
Number of characters. | AlphaNumDigits | ||
showBkgnd : Boolean
Whether or not to display the background graphic. | AlphaNumDigits | ||
val : *
Set and retrieve the display's value. | AlphaNumDigits |
Property | Defined By | ||
---|---|---|---|
_decPl : Number = 0 | AlphaNumDigits | ||
digClip : MovieClip
An instance of the digit skin we use to get its height and width, for overall scaling. | AlphaNumDigits | ||
digCols : Array
An array of Colors to modify the digit graphics (tint). | AlphaNumDigits | ||
digitsContainer : Sprite
Sprite containing all the digits, makes it easier for overall scaling. | AlphaNumDigits | ||
digs : Array
An array of defDigPlusBkgnd clips, for digits 1 - (numDigs-1). | AlphaNumDigits | ||
digSkinClass : Class
Class object for the digit skin. | AlphaNumDigits | ||
_digSkinXClassName : String = defDigXSkinClass | AlphaNumDigits | ||
_digsOn : Boolean = true | AlphaNumDigits | ||
_digTint : int | AlphaNumDigits | ||
_leadZero : Boolean = false | AlphaNumDigits | ||
_leftJust : Boolean = true | AlphaNumDigits | ||
_mode : String = auto | AlphaNumDigits | ||
_numDigs : int = 1 | AlphaNumDigits | ||
pval : * = 0
A private value used to hold the digital display's value. | AlphaNumDigits | ||
_showBkgnd : Boolean = true | AlphaNumDigits |
Method | Defined By | ||
---|---|---|---|
AlphaNumDigits |
Method | Defined By | ||
---|---|---|---|
arrangeDigits(numOfDigits:int):void
Looks at the number of digits needed (and what is there already), then creates
the digits and places them in the data structures for rendering. | AlphaNumDigits | ||
chgDecPlaces(dp:int):void
Changes the number of decimal places displayed. | AlphaNumDigits | ||
chgLeadZero(f:Boolean):void
Sets whether or not to pad the left of decimal point with zeroes (default is false). | AlphaNumDigits | ||
configUI():void [override]
configUI
Get the display objects created in preparation of launch. | AlphaNumDigits | ||
displayDigs(f:Boolean):void
Turn on (true) or off (false) the digital display. | AlphaNumDigits | ||
draw():void [override]
| AlphaNumDigits | ||
setDigColor(c:Number):void
Sets the tint color of the digits (RGB value). | AlphaNumDigits | ||
setVal(v:*):void
Internal routine to change the display value. | AlphaNumDigits | ||
updateDigitDisplay():void
Update, the main routine. | AlphaNumDigits | ||
updateDisplay():void
Update, the main routine. | AlphaNumDigits |
Event | Summary | Defined By | ||
---|---|---|---|---|
Event generated when numeric value is larger (whole numbers) than what can fit in the display to the left of the decimal point. | AlphaNumDigits |
_decPl | property |
protected var _decPl:Number = 0
_digSkinXClassName | property |
protected var _digSkinXClassName:String = defDigXSkinClass
_digsOn | property |
protected var _digsOn:Boolean = true
_digTint | property |
protected var _digTint:int
_leadZero | property |
protected var _leadZero:Boolean = false
_leftJust | property |
protected var _leftJust:Boolean = true
_mode | property |
protected var _mode:String = auto
_numDigs | property |
protected var _numDigs:int = 1
_showBkgnd | property |
protected var _showBkgnd:Boolean = true
decimalPlaces | property |
decimalPlaces:int
Number of decimal places to the right of the decimal point.
public function get decimalPlaces():int
public function set decimalPlaces(value:int):void
digClip | property |
protected var digClip:MovieClip
An instance of the digit skin we use to get its height and width, for overall scaling.
digCols | property |
protected var digCols:Array
An array of Colors to modify the digit graphics (tint).
digitsContainer | property |
protected var digitsContainer:Sprite
Sprite containing all the digits, makes it easier for overall scaling.
digs | property |
protected var digs:Array
An array of defDigPlusBkgnd clips, for digits 1 - (numDigs-1).
digSkinClass | property |
protected var digSkinClass:Class
Class object for the digit skin.
digSkinClassName | property |
digSkinClassName:String
The digSkinClassName lets you change the appearance of the alphanumeric display by using your own
class based on MovieClip, with a structure paralleling the default class, defDigXPlusBkgnd. Specifically,
that class is composed of a MovieClip instance for digits named dig
and a background graphic (MovieClip)
named bkgnd
. Inside the dig
MovieClip, there is are frames
representing each graphical character, and a MovieClip in there named dpt
.
By default, the class name is defDigXPlusBkgnd
.
public function get digSkinClassName():String
public function set digSkinClassName(value:String):void
digTint | property |
digTint:int
Color (int) of each digit, for example, 0xFF0000 is pure red.
public function get digTint():int
public function set digTint(value:int):void
display | property |
display:Boolean
Whether or not to display the digit value. This is used to simulate the display on (true) or off (false).
public function get display():Boolean
public function set display(value:Boolean):void
evtOverflow | property |
public var evtOverflow:String = onOverflow
Event name for event generated if the value of the display exceeds the number of positions. Negative numbers consume one digit to represent the negative sign. If the number exceeds the space, the component puts 8888s in the display.
extendedCharactersFunction | property |
public var extendedCharactersFunction:Function
The default character set does not implement the full set of possible characters -- just alphanumeric. If the developer wants to extend the set with more symbols or special characters, he can add them to the end of the skin class, and then use this function to determine which keyframe to jump to for that character.
extendedCharactersFunction
that accepts a character code (integer, result of getCharCode()
) and the digit movie clip. Your function may look like this:
function extendCharacters(c, mc) {
switch (c) { case 62: mc.gotoAndStop(11); ...
or something like that. Make sure to assign your function to the extendedCharactersFunction
property:
inst.extendedCharactersFunction = extendCharacters;
leadZero | property |
leadZero:Boolean
Boolean property true or false, whether or not to pad left of decimal point with zeroes. This can be set only in the component parameter panel.
public function get leadZero():Boolean
public function set leadZero(value:Boolean):void
leftJust | property |
leftJust:Boolean
If true, the alphanumeric string is left justified, otherwise (default) it is right justified. Note: this only affects strings, not numbers.
public function get leftJust():Boolean
public function set leftJust(value:Boolean):void
mode | property |
mode:String
The 'mode' property can tell the component to render the value in a specific way: auto, number, or text.
public function get mode():String
public function set mode(value:String):void
numDigs | property |
numDigs:int
Number of characters. This can be set only in the component property panel.
public function get numDigs():int
public function set numDigs(value:int):void
pval | property |
protected var pval:* = 0
A private value used to hold the digital display's value.
showBkgnd | property |
showBkgnd:Boolean
Whether or not to display the background graphic.
public function get showBkgnd():Boolean
public function set showBkgnd(value:Boolean):void
val | property |
val:*
Set and retrieve the display's value.
public function get val():*
public function set val(value:any):void
AlphaNumDigits | () | Constructor |
public function AlphaNumDigits()
arrangeDigits | () | method |
protected function arrangeDigits(numOfDigits:int):void
Looks at the number of digits needed (and what is there already), then creates the digits and places them in the data structures for rendering.
Parameters
numOfDigits:int |
chgDecPlaces | () | method |
protected function chgDecPlaces(dp:int):void
Changes the number of decimal places displayed.
Parameters
dp:int — Number of decimal places (0 for none).
|
chgLeadZero | () | method |
protected function chgLeadZero(f:Boolean):void
Sets whether or not to pad the left of decimal point with zeroes (default is false).
Parameters
f:Boolean — Pass in true to pad the display, false not to pad it.
|
configUI | () | method |
override protected function configUI():void
configUI Get the display objects created in preparation of launch. Note that we get called before our constructor, and before we are notified that we are on the stage!
displayDigs | () | method |
protected function displayDigs(f:Boolean):void
Turn on (true) or off (false) the digital display. Note: this does not turn then background off.
Parameters
f:Boolean — Pass in true to show the digits, false to hide them (_visible == false).
|
draw | () | method |
override protected function draw():void
setDigColor | () | method |
protected function setDigColor(c:Number):void
Sets the tint color of the digits (RGB value).
Parameters
c:Number — RGB value of tint color.
|
setVal | () | method |
protected function setVal(v:*):void
Internal routine to change the display value. Note that the internal value may have greater precision than the display since the display is limited to the # of decimal places set.
Parameters
v:* — New value
|
updateDigitDisplay | () | method |
protected function updateDigitDisplay():void
Update, the main routine. This takes the internal value, pval, and translates it into the digital display.
updateDisplay | () | method |
protected function updateDisplay():void
Update, the main routine. This takes the internal value, pval, and translates it into the digital display.
onOverflow | Event |
Event generated when numeric value is larger (whole numbers) than what can fit in the display to the left of the decimal point. Negative numbers consume one digit to represent the negative sign.