home *** CD-ROM | disk | FTP | other *** search
/ T-Online 6 / T-Online.iso / Animation / content / intro / intro.swf / scripts / __Packages / application / ui / DynamicTextField.as < prev    next >
Encoding:
Text File  |  2005-10-20  |  3.2 KB  |  97 lines

  1. class application.ui.DynamicTextField extends MovieClip
  2. {
  3.    var holder;
  4.    var format;
  5.    var format1;
  6.    var dynamicText;
  7.    function DynamicTextField()
  8.    {
  9.       super();
  10.    }
  11.    function build(textW, textH, leftMargin, topMargin, s, holder)
  12.    {
  13.       this.holder = holder;
  14.       this.format = new TextFormat();
  15.       this.format.align = "left";
  16.       this.format.color = 0;
  17.       this.format.font = "Arial";
  18.       this.format.leading = 0;
  19.       this.format.size = 12;
  20.       this.format1 = new TextFormat();
  21.       this.format1.leading = 0;
  22.       this.format1.align = "left";
  23.       this.format1.color = 0;
  24.       this.format1.font = "Arial";
  25.       this.format1.size = 12;
  26.       this.format1.url = "asfunction:onLinkPressed";
  27.       this.createTextField("dynamicText",this.getNextHighestDepth(),leftMargin,topMargin,textW,textH);
  28.       this.dynamicText.setNewTextFormat(this.format);
  29.       this.dynamicText.embedFonts = true;
  30.       this.dynamicText.wordWrap = true;
  31.       this.dynamicText.selectable = false;
  32.       this.dynamicText.multiline = true;
  33.       this.dynamicText.html = true;
  34.       this.dynamicText.border = false;
  35.       var _loc5_ = this.splitString(s);
  36.       this.dynamicText.htmlText = s;
  37.       this.dynamicText.setTextFormat(this.format);
  38.       var _loc2_ = 0;
  39.       while(_loc2_ < _loc5_.length)
  40.       {
  41.          if(_loc5_[_loc2_].style == "format1")
  42.          {
  43.             var _loc6_ = _loc5_[_loc2_].text;
  44.             var _loc4_ = _loc6_.split("<");
  45.             _loc4_ = String(_loc4_[1]).split(">");
  46.             _loc6_ = this.dynamicText.text;
  47.             var _loc3_ = _loc6_.indexOf(String(_loc4_[1]));
  48.             var _loc7_ = _loc3_ + String(_loc4_[1]).length;
  49.             this.dynamicText.setTextFormat(_loc3_,_loc7_,this.format1);
  50.          }
  51.          _loc2_ = _loc2_ + 1;
  52.       }
  53.       s = "<textformat leading=\'0\'>";
  54.       s += this.dynamicText.htmlText;
  55.       s += "<textformat>";
  56.       this.dynamicText.htmlText = s;
  57.       var _loc9_ = this.format.getTextExtent(this.dynamicText.text,textW);
  58.       if(_loc9_.textFieldHeight <= 60)
  59.       {
  60.          this.dynamicText._y = 7;
  61.       }
  62.       else
  63.       {
  64.          this.dynamicText._y = 0;
  65.       }
  66.    }
  67.    function setHolder(holder)
  68.    {
  69.       this.holder = holder;
  70.    }
  71.    function onLinkPressed()
  72.    {
  73.       this.holder.onButtonRelease(this);
  74.    }
  75.    function splitString(s)
  76.    {
  77.       var _loc2_ = [];
  78.       var _loc5_ = s.indexOf("<a",0);
  79.       var _loc3_ = s.indexOf("a>",_loc5_);
  80.       if(_loc5_ != 0)
  81.       {
  82.          _loc2_[0] = {begin:0,end:_loc5_,style:"format",text:s.substr(0,_loc5_)};
  83.          _loc2_[1] = {begin:_loc5_,end:_loc3_ - _loc5_ + 2,style:"format1",text:s.substr(_loc5_,_loc3_ - _loc5_ + 2)};
  84.          if(_loc5_ + (_loc3_ - _loc5_ + 2) != s.length)
  85.          {
  86.             _loc2_[2] = {begin:_loc3_ + 2,end:s.length - (_loc3_ + 2),style:"format",text:s.substr(_loc3_ + 2,s.length - (_loc3_ + 2))};
  87.          }
  88.       }
  89.       else
  90.       {
  91.          _loc2_[0] = {begin:0,end:_loc3_ + 2,style:"format1",text:s.substr(0,_loc3_ + 2)};
  92.          _loc2_[1] = {begin:_loc3_ + 2,end:s.length - (_loc3_ + 2),style:"format",text:s.substr(_loc3_ + 2,s.length - (_loc3_ + 2))};
  93.       }
  94.       return _loc2_;
  95.    }
  96. }
  97.