Packagecom.eqsim.components
Classpublic class AlphaNumDigits
InheritanceAlphaNumDigits Inheritance fl.core.UIComponent

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.



Public Properties
 PropertyDefined 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
Protected Properties
 PropertyDefined 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
Public Methods
 MethodDefined By
  
AlphaNumDigits
Protected Methods
 MethodDefined 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
  
Update, the main routine.
AlphaNumDigits
  
Update, the main routine.
AlphaNumDigits
Events
 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
Property Detail
_decPlproperty
protected var _decPl:Number = 0

_digSkinXClassNameproperty 
protected var _digSkinXClassName:String = defDigXSkinClass

_digsOnproperty 
protected var _digsOn:Boolean = true

_digTintproperty 
protected var _digTint:int

_leadZeroproperty 
protected var _leadZero:Boolean = false

_leftJustproperty 
protected var _leftJust:Boolean = true

_modeproperty 
protected var _mode:String = auto

_numDigsproperty 
protected var _numDigs:int = 1

_showBkgndproperty 
protected var _showBkgnd:Boolean = true

decimalPlacesproperty 
decimalPlaces:int

Number of decimal places to the right of the decimal point.


Implementation
    public function get decimalPlaces():int
    public function set decimalPlaces(value:int):void
digClipproperty 
protected var digClip:MovieClip

An instance of the digit skin we use to get its height and width, for overall scaling.

digColsproperty 
protected var digCols:Array

An array of Colors to modify the digit graphics (tint).

digitsContainerproperty 
protected var digitsContainer:Sprite

Sprite containing all the digits, makes it easier for overall scaling.

digsproperty 
protected var digs:Array

An array of defDigPlusBkgnd clips, for digits 1 - (numDigs-1).

digSkinClassproperty 
protected var digSkinClass:Class

Class object for the digit skin.

digSkinClassNameproperty 
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.


Implementation
    public function get digSkinClassName():String
    public function set digSkinClassName(value:String):void
digTintproperty 
digTint:int

Color (int) of each digit, for example, 0xFF0000 is pure red.


Implementation
    public function get digTint():int
    public function set digTint(value:int):void
displayproperty 
display:Boolean

Whether or not to display the digit value. This is used to simulate the display on (true) or off (false).


Implementation
    public function get display():Boolean
    public function set display(value:Boolean):void
evtOverflowproperty 
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.

extendedCharactersFunctionproperty 
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.


Example
Suppose you want to extend the character set of this component. First duplicate or edit the skin class defDigXGfx, and add your characters at the end of the movie clip in their own keyframes. Then provide a function to 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;
leadZeroproperty 
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.


Implementation
    public function get leadZero():Boolean
    public function set leadZero(value:Boolean):void
leftJustproperty 
leftJust:Boolean

If true, the alphanumeric string is left justified, otherwise (default) it is right justified. Note: this only affects strings, not numbers.


Implementation
    public function get leftJust():Boolean
    public function set leftJust(value:Boolean):void
modeproperty 
mode:String

The 'mode' property can tell the component to render the value in a specific way: auto, number, or text.

  • auto - if the value can be parsed as a number, make it a number, otherwise treat it as a text string
  • number - treat the value only as a number. The component will use parseFloat() to render it as a number
  • text - treat the value as a text string, regardless of whether it could be recognized as a number. Note: there is no built-in character for a period or decimal point when the value is treated as a string.

  • Implementation
        public function get mode():String
        public function set mode(value:String):void
    numDigsproperty 
    numDigs:int

    Number of characters. This can be set only in the component property panel.


    Implementation
        public function get numDigs():int
        public function set numDigs(value:int):void
    pvalproperty 
    protected var pval:* = 0

    A private value used to hold the digital display's value.

    showBkgndproperty 
    showBkgnd:Boolean

    Whether or not to display the background graphic.


    Implementation
        public function get showBkgnd():Boolean
        public function set showBkgnd(value:Boolean):void
    valproperty 
    val:*

    Set and retrieve the display's value.


    Implementation
        public function get val():*
        public function set val(value:any):void
    Constructor Detail
    AlphaNumDigits()Constructor
    public function AlphaNumDigits()

    Method Detail
    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.

    Event Detail
    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.