4 Replies Latest reply on Mar 4, 2010 7:45 AM by ssettlemyre

    Monospaced font not displaying as monospaced in TextInput

    Gregory Lafrance Level 6

      I'm wondering why the font in this class is not displaying as monospaced:

       

      package
      {
        import flash.display.Sprite;
        
        import mx.controls.TextInput;
        import mx.events.FlexEvent;
        public class CombFieldCompTI extends TextInput{
          private var _spacing:Number = 0;
              
          [Bindable] private var _text:String = "";
          public function CombFieldCompTI(){
            super();
            setStyle("fontFamily", "_typewriter");
            setCustFormat();
            this.addEventListener(FlexEvent.CREATION_COMPLETE, init);
          }
          
          private function init(evt:FlexEvent):void{
            setCustFormat();
          }
          override public function set text(value:String):void{
            super.text = value;
            setCustFormat();
          }
          public function get spacing():Number{
            return _spacing;
          }
          
          public function set spacing(value:Number):void{
            _spacing = value;
            setCustFormat();
          }
          
          private function setCustFormat():void{
            setStyle("letterSpacing", _spacing);
            var lines:Sprite = new Sprite();
            lines.graphics.lineStyle(1,0x000000);
            for(var a:Number=1;a<length;a++){
              var Xpos:Number = (width / length) * a;
              lines.graphics.moveTo(Xpos, height);
              lines.graphics.lineTo(Xpos, 0);
            }
            addChild(lines);      
          }
        }
      }