home *** CD-ROM | disk | FTP | other *** search
- package classes.basic.Button
- {
- import classes.basic.Events.TFEvent;
- import flash.display.MovieClip;
- import flash.text.*;
-
- public class TFTextButton extends TFButton
- {
-
-
- private var textValue:String;
-
- private var eventHandler:Function;
-
- private var vertAlignInitY:Number;
-
- private var vertAlignFinishY:Number;
-
- public function TFTextButton(param1:MovieClip, param2:String, param3:Function)
- {
- this.textValue = param2;
- this.eventHandler = param3;
- this.vertAlignInitY = -1;
- this.vertAlignFinishY = -1;
- super(param1,onBtnEvent);
- }
-
- private function updateVertAlign() : *
- {
- if(this.vertAlignFinishY == -1 || this.vertAlignInitY == -1)
- {
- return;
- }
- if(movieClip.out != undefined)
- {
- updateVertAlignMovieClip(movieClip.out);
- }
- if(movieClip.over != undefined)
- {
- updateVertAlignMovieClip(movieClip.over);
- }
- if(movieClip.down != undefined)
- {
- updateVertAlignMovieClip(movieClip.down);
- }
- if(movieClip.disable != undefined)
- {
- updateVertAlignMovieClip(movieClip.disable);
- }
- }
-
- public function setVertAlign(param1:Number, param2:Number) : *
- {
- this.vertAlignInitY = param1;
- this.vertAlignFinishY = param2;
- if(this.vertAlignFinishY == -1 || this.vertAlignInitY == -1)
- {
- return;
- }
- updateVertAlign();
- }
-
- protected function onBtnEvent(param1:TFEvent) : *
- {
- switch(param1.event)
- {
- case TFEvent.EVENT_MOUSECLICK:
- break;
- case TFEvent.EVENT_INIT:
- onEventInit();
- break;
- case TFEvent.EVENT_MOUSEOUT:
- case TFEvent.EVENT_MOUSEOVER:
- }
- if(eventHandler != null)
- {
- eventHandler(param1);
- }
- }
-
- private function setTexts() : *
- {
- if(movieClip.out != undefined)
- {
- movieClip.out.txtText.text = textValue;
- }
- if(movieClip.over != undefined)
- {
- movieClip.over.txtText.text = textValue;
- }
- if(movieClip.down != undefined)
- {
- movieClip.down.txtText.text = textValue;
- }
- if(movieClip.disable != undefined)
- {
- movieClip.disabled.txtText.text = textValue;
- }
- updateVertAlign();
- }
-
- private function updateVertAlignMovieClip(param1:MovieClip) : *
- {
- var _loc2_:Number = NaN;
- var _loc3_:Number = NaN;
- if(this.vertAlignFinishY - this.vertAlignInitY < _loc2_)
- {
- param1.txtText.y = this.vertAlignInitY;
- }
- else
- {
- _loc2_ = Number(param1.txtText.textHeight);
- _loc3_ = this.vertAlignFinishY - this.vertAlignInitY - _loc2_;
- _loc3_ /= 2;
- _loc3_ = Math.floor(_loc3_);
- param1.txtText.y = this.vertAlignInitY + _loc3_;
- if(param1.txtText.y < this.vertAlignInitY)
- {
- param1.txtText.y = this.vertAlignInitY;
- }
- }
- }
-
- public function setText(param1:String) : *
- {
- this.textValue = param1;
- setTexts();
- }
-
- protected function onEventInit() : *
- {
- if(textValue != null)
- {
- setTexts();
- }
- }
- }
- }
-