home *** CD-ROM | disk | FTP | other *** search
/ Practice Anatomy Lab / PAL.ISO / pc / PAL.swf / scripts / __Packages / com / argosy / ui / InputField.as < prev    next >
Encoding:
Text File  |  2007-03-19  |  2.9 KB  |  105 lines

  1. class com.argosy.ui.InputField extends com.argosy.ui.baseUI
  2. {
  3.    var text_tf;
  4.    var text_format;
  5.    var bg;
  6.    var outline_mc;
  7.    var drop_shadow;
  8.    var dispatchEvent;
  9.    function InputField()
  10.    {
  11.       super();
  12.    }
  13.    function setLimit(limit_num, limit_str)
  14.    {
  15.       this.text_tf.maxChars = limit_num;
  16.       this.text_tf.restrict = limit_str;
  17.    }
  18.    function set text(str)
  19.    {
  20.       this.text_tf.text = str;
  21.    }
  22.    function get text()
  23.    {
  24.       return this.text_tf.text;
  25.    }
  26.    function set type(str)
  27.    {
  28.       this.text_tf.type = str;
  29.    }
  30.    function get type()
  31.    {
  32.       return this.text_tf.type;
  33.    }
  34.    function set textEnabled(b)
  35.    {
  36.       if(b)
  37.       {
  38.          this.text_tf.type = "input";
  39.       }
  40.       else
  41.       {
  42.          this.text_tf.type = "dynamic";
  43.       }
  44.    }
  45.    function init()
  46.    {
  47.       this.text_format = new TextFormat();
  48.       this.text_format.font = "Frutiger";
  49.       this.text_format.size = 14;
  50.       this.text_format.color = 2046576;
  51.       this.text_format.kerning = true;
  52.       this.text_format.align = "left";
  53.       super.init();
  54.    }
  55.    function createChildren()
  56.    {
  57.       this.bg = this.createEmptyMovieClip("bg",1);
  58.       this.outline_mc = this.createEmptyMovieClip("menu",2);
  59.       this.outline_mc._visible = false;
  60.       this.text_tf = this.createTextField("text_tf",3,0,0,this.width,this.height);
  61.       this.text_tf.type = "input";
  62.       this.text_tf.embedFonts = true;
  63.       this.text_tf.setNewTextFormat(this.text_format);
  64.       this.text_tf.onSetFocus = ascb.util.Proxy.create(this,this.gainFocus);
  65.       this.text_tf.onKillFocus = ascb.util.Proxy.create(this,this.loseFocus);
  66.       this.text_tf.onChanged = ascb.util.Proxy.create(this,this.textChanged);
  67.       this.text_tf.tabIndex = 1;
  68.       this.drop_shadow = new flash.filters.DropShadowFilter(0,0,0,0.8,5,5,1,3,true,false,false);
  69.    }
  70.    function textChanged()
  71.    {
  72.       this.dispatchEvent({type:"textChanged",target:this.text_tf});
  73.    }
  74.    function gainFocus()
  75.    {
  76.       this.outline_mc._visible = true;
  77.    }
  78.    function loseFocus()
  79.    {
  80.       this.outline_mc._visible = false;
  81.    }
  82.    function layout()
  83.    {
  84.       this.bg.clear();
  85.       this.bg.lineStyle(0,13421772,100);
  86.       this.bg.beginFill(16777215,100);
  87.       this.bg.lineTo(this.width,0);
  88.       this.bg.lineTo(this.width,this.height);
  89.       this.bg.lineTo(0,this.height);
  90.       this.bg.lineTo(0,0);
  91.       this.bg.endFill();
  92.       this.bg.filters = [this.drop_shadow];
  93.       this.outline_mc.clear();
  94.       this.outline_mc.lineStyle(2,4426936,100);
  95.       this.outline_mc.lineTo(this.width,0);
  96.       this.outline_mc.lineTo(this.width,this.height);
  97.       this.outline_mc.lineTo(0,this.height);
  98.       this.outline_mc.lineTo(0,0);
  99.       this.text_tf._y = 2;
  100.       this.text_tf._x = 2;
  101.       this.text_tf._width = this.width - 4;
  102.       this.text_tf._height = this.height - 4;
  103.    }
  104. }
  105.