topical media & game development

talk show tell print

flex-led-array.mx

flex-led-array.mx [swf] flex


  <?xml version="1.0" encoding="utf-8"?>
  <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:Script>
          <![CDATA[
              
              private var _text:String;
              [Bindable]
              public var charThick:Number = 4;
              [Bindable]
              public var charH:Number = 60;
              [Bindable]
              public var charW:Number = 30;
              [Bindable]
              public var charSkew:Number = 5;
              [Bindable]
              public var charType:uint = flex_led_char.DISPLAY_16_SEG;
              [Bindable]
              public var charOnColor:uint = 0xFF0000;
              [Bindable]
              public var charOffColor:uint = 0x330000;
              
              public function refresh():void
              {
                  text = _text;
              }
              
              public function set text(str:String):void
              {
                  _text = str.toUpperCase();
                  //this is wasteful, but easy, to remove and re-add all characters
                  this.removeAllChildren();
                  for(var i:int = 0;i<_text.length;i++)
                  {
                      var led:flex_led_char = new flex_led_char();
                      led.displayType = charType;
                      led.onColor = charOnColor;
                      led.offColor = charOffColor;
                      led.width = charW;
                      led.height = charH;
                      led.skew = charSkew;
                      led.thickness = charThick;
                      
                      led.interpretChar(_text.substr(i,1));
                      this.addChild(led);
                  }
              }
              
              public function set value(val:Number):void
              {
                  text = val.toString();
              }
          ]]>
      </mx:Script>
  </mx:HBox>
  


(C) Æliens 27/08/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.