home *** CD-ROM | disk | FTP | other *** search
/ Ice Age Fan CD 1 / CD1_Scrat.iso / flash / data / game.swf / scripts / com / google / analytics / debug / Label.as < prev    next >
Encoding:
Text File  |  2012-07-04  |  3.5 KB  |  135 lines

  1. package com.google.analytics.debug
  2. {
  3.    import flash.display.Graphics;
  4.    import flash.display.Shape;
  5.    import flash.events.TextEvent;
  6.    import flash.text.TextField;
  7.    import flash.text.TextFieldAutoSize;
  8.    import flash.text.TextFieldType;
  9.    
  10.    public class Label extends UISprite
  11.    {
  12.       public static var count:uint = 0;
  13.       
  14.       private var _color:uint;
  15.       
  16.       private var _background:Shape;
  17.       
  18.       private var _textField:TextField;
  19.       
  20.       public var stickToEdge:Boolean;
  21.       
  22.       private var _text:String;
  23.       
  24.       protected var selectable:Boolean;
  25.       
  26.       private var _tag:String;
  27.       
  28.       public function Label(param1:String = "", param2:String = "uiLabel", param3:uint = 0, param4:Align = null, param5:Boolean = false)
  29.       {
  30.          super();
  31.          this.name = "Label" + count++;
  32.          selectable = false;
  33.          _background = new Shape();
  34.          _textField = new TextField();
  35.          _text = param1;
  36.          _tag = param2;
  37.          if(param4 == null)
  38.          {
  39.             param4 = Align.none;
  40.          }
  41.          this.alignement = param4;
  42.          this.stickToEdge = param5;
  43.          if(param3 == 0)
  44.          {
  45.             param3 = uint(Style.backgroundColor);
  46.          }
  47.          _color = param3;
  48.          _textField.addEventListener(TextEvent.LINK,onLink);
  49.       }
  50.       
  51.       public function get tag() : String
  52.       {
  53.          return _tag;
  54.       }
  55.       
  56.       private function _draw() : void
  57.       {
  58.          var _loc1_:Graphics = _background.graphics;
  59.          _loc1_.clear();
  60.          _loc1_.beginFill(_color);
  61.          var _loc2_:uint = _textField.width;
  62.          var _loc3_:uint = _textField.height;
  63.          if(forcedWidth > 0)
  64.          {
  65.             _loc2_ = forcedWidth;
  66.          }
  67.          Background.drawRounded(this,_loc1_,_loc2_,_loc3_);
  68.          _loc1_.endFill();
  69.       }
  70.       
  71.       public function get text() : String
  72.       {
  73.          return _textField.text;
  74.       }
  75.       
  76.       public function appendText(param1:String, param2:String = "") : void
  77.       {
  78.          if(param1 == "")
  79.          {
  80.             return;
  81.          }
  82.          if(param2 == "")
  83.          {
  84.             param2 = tag;
  85.          }
  86.          _textField.htmlText += "<span class=\"" + param2 + "\">" + param1 + "</span>";
  87.          _text += param1;
  88.          _draw();
  89.          resize();
  90.       }
  91.       
  92.       public function set text(param1:String) : void
  93.       {
  94.          if(param1 == "")
  95.          {
  96.             param1 = _text;
  97.          }
  98.          _textField.htmlText = "<span class=\"" + tag + "\">" + param1 + "</span>";
  99.          _text = param1;
  100.          _draw();
  101.          resize();
  102.       }
  103.       
  104.       override protected function layout() : void
  105.       {
  106.          _textField.type = TextFieldType.DYNAMIC;
  107.          _textField.autoSize = TextFieldAutoSize.LEFT;
  108.          _textField.background = false;
  109.          _textField.selectable = selectable;
  110.          _textField.multiline = true;
  111.          _textField.styleSheet = Style.sheet;
  112.          this.text = _text;
  113.          addChild(_background);
  114.          addChild(_textField);
  115.       }
  116.       
  117.       public function set tag(param1:String) : void
  118.       {
  119.          _tag = param1;
  120.          text = "";
  121.       }
  122.       
  123.       public function onLink(param1:TextEvent) : void
  124.       {
  125.       }
  126.       
  127.       override protected function dispose() : void
  128.       {
  129.          _textField.removeEventListener(TextEvent.LINK,onLink);
  130.          super.dispose();
  131.       }
  132.    }
  133. }
  134.  
  135.