home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / beauty_resort.swf / scripts / classes / basic / Button / TFTextButton.as < prev   
Encoding:
Text File  |  2008-09-04  |  3.7 KB  |  139 lines

  1. package classes.basic.Button
  2. {
  3.    import classes.basic.Events.TFEvent;
  4.    import flash.display.MovieClip;
  5.    import flash.text.*;
  6.    
  7.    public class TFTextButton extends TFButton
  8.    {
  9.        
  10.       
  11.       private var textValue:String;
  12.       
  13.       private var eventHandler:Function;
  14.       
  15.       private var vertAlignInitY:Number;
  16.       
  17.       private var vertAlignFinishY:Number;
  18.       
  19.       public function TFTextButton(param1:MovieClip, param2:String, param3:Function)
  20.       {
  21.          this.textValue = param2;
  22.          this.eventHandler = param3;
  23.          this.vertAlignInitY = -1;
  24.          this.vertAlignFinishY = -1;
  25.          super(param1,onBtnEvent);
  26.       }
  27.       
  28.       private function updateVertAlign() : *
  29.       {
  30.          if(this.vertAlignFinishY == -1 || this.vertAlignInitY == -1)
  31.          {
  32.             return;
  33.          }
  34.          if(movieClip.out != undefined)
  35.          {
  36.             updateVertAlignMovieClip(movieClip.out);
  37.          }
  38.          if(movieClip.over != undefined)
  39.          {
  40.             updateVertAlignMovieClip(movieClip.over);
  41.          }
  42.          if(movieClip.down != undefined)
  43.          {
  44.             updateVertAlignMovieClip(movieClip.down);
  45.          }
  46.          if(movieClip.disable != undefined)
  47.          {
  48.             updateVertAlignMovieClip(movieClip.disable);
  49.          }
  50.       }
  51.       
  52.       public function setVertAlign(param1:Number, param2:Number) : *
  53.       {
  54.          this.vertAlignInitY = param1;
  55.          this.vertAlignFinishY = param2;
  56.          if(this.vertAlignFinishY == -1 || this.vertAlignInitY == -1)
  57.          {
  58.             return;
  59.          }
  60.          updateVertAlign();
  61.       }
  62.       
  63.       protected function onBtnEvent(param1:TFEvent) : *
  64.       {
  65.          switch(param1.event)
  66.          {
  67.             case TFEvent.EVENT_MOUSECLICK:
  68.                break;
  69.             case TFEvent.EVENT_INIT:
  70.                onEventInit();
  71.                break;
  72.             case TFEvent.EVENT_MOUSEOUT:
  73.             case TFEvent.EVENT_MOUSEOVER:
  74.          }
  75.          if(eventHandler != null)
  76.          {
  77.             eventHandler(param1);
  78.          }
  79.       }
  80.       
  81.       private function setTexts() : *
  82.       {
  83.          if(movieClip.out != undefined)
  84.          {
  85.             movieClip.out.txtText.text = textValue;
  86.          }
  87.          if(movieClip.over != undefined)
  88.          {
  89.             movieClip.over.txtText.text = textValue;
  90.          }
  91.          if(movieClip.down != undefined)
  92.          {
  93.             movieClip.down.txtText.text = textValue;
  94.          }
  95.          if(movieClip.disable != undefined)
  96.          {
  97.             movieClip.disabled.txtText.text = textValue;
  98.          }
  99.          updateVertAlign();
  100.       }
  101.       
  102.       private function updateVertAlignMovieClip(param1:MovieClip) : *
  103.       {
  104.          var _loc2_:Number = NaN;
  105.          var _loc3_:Number = NaN;
  106.          if(this.vertAlignFinishY - this.vertAlignInitY < _loc2_)
  107.          {
  108.             param1.txtText.y = this.vertAlignInitY;
  109.          }
  110.          else
  111.          {
  112.             _loc2_ = Number(param1.txtText.textHeight);
  113.             _loc3_ = this.vertAlignFinishY - this.vertAlignInitY - _loc2_;
  114.             _loc3_ /= 2;
  115.             _loc3_ = Math.floor(_loc3_);
  116.             param1.txtText.y = this.vertAlignInitY + _loc3_;
  117.             if(param1.txtText.y < this.vertAlignInitY)
  118.             {
  119.                param1.txtText.y = this.vertAlignInitY;
  120.             }
  121.          }
  122.       }
  123.       
  124.       public function setText(param1:String) : *
  125.       {
  126.          this.textValue = param1;
  127.          setTexts();
  128.       }
  129.       
  130.       protected function onEventInit() : *
  131.       {
  132.          if(textValue != null)
  133.          {
  134.             setTexts();
  135.          }
  136.       }
  137.    }
  138. }
  139.