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

  1. class com.argosy.ui.CButton extends com.argosy.ui.baseUI
  2. {
  3.    var label_str;
  4.    var label_tf;
  5.    var button_style;
  6.    var button_bg;
  7.    var glow_filter;
  8.    var drop_shadow;
  9.    var dispatchEvent;
  10.    var button_height = 20;
  11.    function CButton()
  12.    {
  13.       super();
  14.    }
  15.    function set label(str)
  16.    {
  17.       this.label_str = str;
  18.       this.label_tf.htmlText = "<p><up>" + this.label_str + "</up></p>";
  19.       this.setSize(this.label_tf._width * 1.5,this.button_height);
  20.    }
  21.    function get label()
  22.    {
  23.       return this.label_str;
  24.    }
  25.    function init()
  26.    {
  27.       this.button_style = new TextField.StyleSheet();
  28.       this.button_style.setStyle("up",{fontFamily:"Frutiger Bold",fontSize:"10",color:"#000000",textAlign:"center",textDecoration:"none",kerning:"true",letterSpacing:"0"});
  29.       this.button_style.setStyle("over",{fontFamily:"Frutiger Bold",fontSize:"10",color:"#438CB8",textAlign:"center",textDecoration:"none",kerning:"true",letterSpacing:"0"});
  30.       super.init();
  31.       this.label = "Button";
  32.    }
  33.    function createChildren()
  34.    {
  35.       this.button_bg = this.createEmptyMovieClip("button_bg",1);
  36.       this.label_tf = this._createTextField(this,"label_tf",2,0,5,1,1,this.button_style,"");
  37.       this.label_tf.autoSize = true;
  38.       this.glow_filter = new flash.filters.GlowFilter(4426936,1,5,5,1,3,false,false);
  39.       this.drop_shadow = new flash.filters.DropShadowFilter(2,45,0,1,5,5,1,3,false,false,false);
  40.       this.button_bg.filters = [this.drop_shadow];
  41.       this.button_bg.onRollOver = ascb.util.Proxy.create(this,this._rollOver);
  42.       this.button_bg.onRollOut = ascb.util.Proxy.create(this,this._rollOut);
  43.       this.button_bg.onPress = ascb.util.Proxy.create(this,this._press);
  44.       this.button_bg.onRelease = ascb.util.Proxy.create(this,this._release);
  45.       this.button_bg.onReleaseOutside = ascb.util.Proxy.create(this,this._rollOut);
  46.    }
  47.    function _rollOver()
  48.    {
  49.       this.label_tf.htmlText = "<p><over>" + this.label_str + "</over></p>";
  50.       this.button_bg.filters = [this.glow_filter,this.drop_shadow];
  51.    }
  52.    function _rollOut()
  53.    {
  54.       this.label_tf.htmlText = "<p><up>" + this.label_str + "</up></p>";
  55.       this.button_bg.filters = [this.drop_shadow];
  56.    }
  57.    function _press()
  58.    {
  59.       this.label_tf.htmlText = "<p><over>" + this.label_str + "</over></p>";
  60.       this.button_bg.filters = [this.glow_filter,this.drop_shadow];
  61.       this.dispatchEvent({type:"press",target:this});
  62.    }
  63.    function _release()
  64.    {
  65.       this.label_tf.htmlText = "<p><up>" + this.label_str + "</up></p>";
  66.       this.button_bg.filters = [this.drop_shadow];
  67.       this.dispatchEvent({type:"release",target:this});
  68.    }
  69.    function layout()
  70.    {
  71.       this.label_tf._x = this.width / 2 - this.label_tf.textWidth / 2 - 2;
  72.       this.label_tf._y = this.height / 2 - this.label_tf.textHeight / 2 - 2;
  73.       this.button_bg.clear();
  74.       var _loc2_ = new flash.geom.Matrix();
  75.       _loc2_.createGradientBox(this.width,this.height,1.5707963267948966,0,0);
  76.       this.button_bg.lineStyle(1,0,100);
  77.       this.button_bg.beginFill(16777215,100);
  78.       com.drawing.drawUtil.drawRect(this.button_bg,0,0,this.width,this.height,0);
  79.       this.button_bg.endFill();
  80.    }
  81. }
  82.