Packagecom.williammalone
Classpublic class Digit
InheritanceDigit Inheritance flash.display.Sprite

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 9

The Digit control is a seven-segment display which has a integer value of 0-9 or NONE.

View the examples

See also

http://www.williammalone.com/articles/seven-segment_display/


Public Properties
 PropertyDefined By
  color : uint
The color of the digit.
Digit
  height : Number
[override] The height of the digit.
Digit
  padding : Number
[read-only] The space between segments in pixels.
Digit
  thickness : Number
[read-only] The thickness of each segment.
Digit
  value : int
The value of the digit which is either an integer 0-9 or a value of NONE.
Digit
  width : Number
[override] [read-only] The width of the digit (based on a ratio of the height and cannot be set).
Digit
Public Methods
 MethodDefined By
  
Creates a new Digit instance.
Digit
Public Constants
 ConstantDefined By
  A : int = 0
[static] Constant associated with the segment at the top of the digit.
Digit
  B : int = 1
[static] Constant associated with the segment at the top-right of the digit.
Digit
  C : int = 2
[static] Constant associated with the segment at the bottom-right of the digit.
Digit
  D : int = 3
[static] Constant associated with the segment at the bottom of the digit.
Digit
  E : int = 4
[static] Constant associated with the segment at the bottom-left of the digit.
Digit
  F : int = 5
[static] Constant associated with the segment at the top-left of the digit.
Digit
  G : int = 6
[static] Constant associated with the segment at the middle of the digit.
Digit
  NONE : int = -1
[static] Constant specifing all segments are in the off state.
Digit
Property Detail
colorproperty
color:uint

The color of the digit.


Implementation
    public function get color():uint
    public function set color(value:uint):void
heightproperty 
height:Number[override]

The height of the digit.


Implementation
    public function get height():Number
    public function set height(value:Number):void
paddingproperty 
padding:Number  [read-only]

The space between segments in pixels.


Implementation
    public function get padding():Number
thicknessproperty 
thickness:Number  [read-only]

The thickness of each segment.


Implementation
    public function get thickness():Number
valueproperty 
value:int

The value of the digit which is either an integer 0-9 or a value of NONE.

The default value is NONE.


Implementation
    public function get value():int
    public function set value(value:int):void
widthproperty 
width:Number  [read-only] [override]

The width of the digit (based on a ratio of the height and cannot be set).


Implementation
    public function get width():Number
Constructor Detail
Digit()Constructor
public function Digit()

Creates a new Digit instance.

Constant Detail
AConstant
public static const A:int = 0

Constant associated with the segment at the top of the digit.

BConstant 
public static const B:int = 1

Constant associated with the segment at the top-right of the digit.

CConstant 
public static const C:int = 2

Constant associated with the segment at the bottom-right of the digit.

DConstant 
public static const D:int = 3

Constant associated with the segment at the bottom of the digit.

EConstant 
public static const E:int = 4

Constant associated with the segment at the bottom-left of the digit.

FConstant 
public static const F:int = 5

Constant associated with the segment at the top-left of the digit.

GConstant 
public static const G:int = 6

Constant associated with the segment at the middle of the digit.

NONEConstant 
public static const NONE:int = -1

Constant specifing all segments are in the off state.

Examples
The following example uses the DigitExample class to create a new digit on the stage. The digit values are controlled by a combo box.
     
    package {
        import com.williammalone.Digit;
        import fl.controls.ComboBox;
       
        public class DigitExample extends Digit {
            private var digit:Digit;
            private var digitHeight:Number = 100;
            private var digitColor:uint = 0x557755;
            
            public function DigitExample() {
                digit = new Digit();
                digit.color = digitColor;
                addChild(digit);
                createComboBox();
            }
      
            private function createComboBox():void {
                var changeDigit:ComboBox = new ComboBox();
                changeDigit.width = 120;
                changeDigit.x = 40;
                changeDigit.y = 10;
                changeDigit.prompt = "Select a digit";
                changeDigit.addItem( { label: "0", data:0 } );
                changeDigit.addItem( { label: "1", data:1 } );
                changeDigit.addItem( { label: "2", data:2 } );
                changeDigit.addItem( { label: "3", data:3 } );
                changeDigit.addItem( { label: "4", data:4 } );
                changeDigit.addItem( { label: "5", data:5 } );
                changeDigit.addItem( { label: "6", data:6 } );
                changeDigit.addItem( { label: "7", data:7 } );
                changeDigit.addItem( { label: "8", data:8 } );
                changeDigit.addItem( { label: "9", data:9 } );
                addChild(changeDigit);
                changeDigit.addEventListener(Event.CHANGE, onDigitChanged);
            }
          
            private function onDigitChanged(e:Event):void {
                digit.value = changeDigit.selectedItem.data;
            }
        }
    }