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

  1. class application.ui.DynamicInfoTextfield extends MovieClip
  2. {
  3.    var instCounter;
  4.    var maxWidth;
  5.    var maxHeight;
  6.    var tfAspectRatio;
  7.    var dataObj;
  8.    var holder;
  9.    var textArray;
  10.    function DynamicInfoTextfield()
  11.    {
  12.       super();
  13.       this.instCounter = 1;
  14.       this.maxWidth = 421;
  15.       this.maxHeight = 285;
  16.       this.tfAspectRatio = this.maxWidth / this.maxHeight;
  17.    }
  18.    function run(id)
  19.    {
  20.       this.splitString(id);
  21.       var _loc2_ = this.showInfo(id);
  22.       return _loc2_;
  23.    }
  24.    function setDataObj(dataObj)
  25.    {
  26.       this.dataObj = dataObj;
  27.    }
  28.    function setContainer(holder)
  29.    {
  30.       this.holder = holder;
  31.    }
  32.    function showInfo(i)
  33.    {
  34.       var _loc16_ = this.dataObj.software.contentList[i];
  35.       if(_loc16_.information == "")
  36.       {
  37.          return null;
  38.       }
  39.       var _loc6_ = this.holder.createEmptyMovieClip("info",this.instCounter++);
  40.       var _loc12_ = _loc6_.createEmptyMovieClip("background",1);
  41.       _loc6_.createTextField("tf",2,0,0,this.maxWidth,this.maxHeight);
  42.       var _loc3_ = _loc6_.tf;
  43.       _loc3_.multiline = true;
  44.       _loc3_.wordWrap = true;
  45.       _loc3_.embedFonts = true;
  46.       _loc3_.selectable = false;
  47.       _loc3_.html = true;
  48.       _loc3_.styleSheet = _global.CSS;
  49.       _loc3_.text = _loc16_.information;
  50.       if(_loc3_.maxscroll == 1)
  51.       {
  52.          var _loc19_ = int(_loc3_._width);
  53.          var _loc10_ = 0;
  54.          var _loc9_ = _loc19_;
  55.          var _loc11_ = -1;
  56.          i = 0;
  57.          while(i < 10)
  58.          {
  59.             if(_loc3_.maxscroll == 1 && _loc3_._height <= this.maxHeight)
  60.             {
  61.                _loc11_ = -1;
  62.                if(_loc3_._width < _loc9_)
  63.                {
  64.                   _loc9_ = int(_loc3_._width);
  65.                }
  66.             }
  67.             else
  68.             {
  69.                _loc11_ = 1;
  70.                if(_loc3_._width > _loc10_)
  71.                {
  72.                   _loc10_ = int(_loc3_._width);
  73.                }
  74.             }
  75.             _loc19_ = int(_loc3_._width + _loc11_ * ((_loc9_ - _loc10_) / 2));
  76.             _loc3_._width = _loc19_;
  77.             _loc3_._height = _loc19_ / this.tfAspectRatio;
  78.             _loc3_.embedFonts = true;
  79.             _loc3_.border = false;
  80.             _loc3_.html = true;
  81.             _loc3_.wordWrap = true;
  82.             _loc3_.multiline = true;
  83.             _loc3_.styleSheet = _global.CSS;
  84.             _loc3_.text = _loc16_.information;
  85.             i = i + 1;
  86.          }
  87.          _loc19_ = _loc9_;
  88.          _loc3_._width = _loc19_;
  89.          _loc3_._height = int(_loc19_ / this.tfAspectRatio);
  90.          _loc3_.embedFonts = true;
  91.          _loc3_.border = false;
  92.          _loc3_.selectable = false;
  93.          _loc3_.html = true;
  94.          _loc3_.wordWrap = true;
  95.          _loc3_.multiline = true;
  96.          _loc3_.styleSheet = _global.CSS;
  97.          _loc3_.text = _loc16_.information;
  98.          var _loc13_ = 0;
  99.          var _loc8_ = 1;
  100.          this.instCounter = this.instCounter + 1;
  101.          var _loc4_ = 10;
  102.          _loc9_ = 0;
  103.          i = 0;
  104.          while(i < this.textArray.length)
  105.          {
  106.             if(this.textArray[i].type == "text")
  107.             {
  108.                _loc6_.createTextField("tf" + _loc4_,this.instCounter++,_loc13_,_loc8_,_loc19_,22);
  109.                var _loc5_ = _loc6_["tf" + _loc4_];
  110.                _loc5_.embedFonts = true;
  111.                _loc5_.selectable = false;
  112.                _loc5_.border = false;
  113.                _loc5_.html = true;
  114.                _loc5_.wordWrap = true;
  115.                _loc5_.multiline = true;
  116.                _loc5_.styleSheet = _global.CSS;
  117.                _loc5_.htmlText = this.textArray[i].data;
  118.                _loc5_._height = int(_loc5_.maxscroll * 22);
  119.                _loc8_ += int(_loc5_.textHeight);
  120.                if(_loc5_.textWidth > _loc9_)
  121.                {
  122.                   _loc9_ = int(_loc5_.textWidth);
  123.                }
  124.                _loc5_.autoSize = true;
  125.                _loc4_ = _loc4_ + 1;
  126.             }
  127.             else
  128.             {
  129.                _loc6_.createTextField("tf" + _loc4_,this.instCounter++,35,_loc8_,_loc19_ - 35,22);
  130.                _loc5_ = _loc6_["tf" + _loc4_];
  131.                _loc5_.embedFonts = true;
  132.                _loc5_.selectable = false;
  133.                _loc5_.border = false;
  134.                _loc5_.html = true;
  135.                _loc5_.wordWrap = true;
  136.                _loc5_.multiline = true;
  137.                _loc5_.styleSheet = _global.CSS;
  138.                _loc5_.text = this.textArray[i].data;
  139.                _loc5_._height = int(_loc5_.maxscroll * 22);
  140.                _loc4_ = _loc4_ + 1;
  141.                _loc6_.createTextField("tf" + _loc4_,this.instCounter++,25,_loc8_,20,20);
  142.                _loc8_ += int(_loc5_.textHeight);
  143.                if(_loc5_.textWidth + 35 > _loc9_)
  144.                {
  145.                   _loc9_ = int(_loc5_.textWidth + 35);
  146.                }
  147.                _loc5_ = _loc6_["tf" + _loc4_];
  148.                _loc5_.embedFonts = true;
  149.                _loc5_.selectable = false;
  150.                _loc5_.border = false;
  151.                _loc5_.html = true;
  152.                _loc5_.wordWrap = true;
  153.                _loc5_.multiline = true;
  154.                _loc5_.htmlText = "<TEXTFORMAT LEADING=\"2\"><FONT FACE=\"Testfont\" SIZE=\"16\" COLOR=\"#000000\">#</FONT></TEXTFORMAT>";
  155.                _loc4_ = _loc4_ + 1;
  156.             }
  157.             i = i + 1;
  158.          }
  159.          _loc12_.clear();
  160.          _loc12_.beginFill(16777215,100);
  161.          _loc12_.lineStyle(1,0,100);
  162.          _loc12_.moveTo(0,0);
  163.          _loc12_.lineTo(0,_loc8_ + 3 + 24);
  164.          _loc12_.lineTo(_loc9_ + 2 + 24,_loc8_ + 3 + 24);
  165.          _loc12_.lineTo(_loc9_ + 2 + 24,0);
  166.          _loc12_.lineTo(0,0);
  167.          _loc12_.endFill();
  168.          var _loc15_ = _loc12_._width;
  169.          var _loc14_ = _loc12_._height;
  170.          var _loc17_ = _loc12_.attachMovie("infoBackground","infoBackground",1);
  171.          _loc17_.tc._width = int(_loc15_ - 5);
  172.          _loc17_.tr._x = _loc17_.tc._x + _loc17_.tc._width;
  173.          _loc17_.cl._height = int(_loc14_ - 8);
  174.          _loc17_.cr._height = _loc14_ - 5;
  175.          _loc17_.cr._x = _loc17_.tr._x;
  176.          _loc17_.br._y = _loc17_.cl._height + _loc17_.cl._y;
  177.          _loc17_.br._x = _loc17_.tr._x;
  178.          _loc17_.bl._y = _loc17_.br._y;
  179.          _loc17_.bc._y = _loc17_.br._y;
  180.          _loc17_.bc._width = _loc17_.tc._width;
  181.          _loc12_._x -= 12;
  182.          _loc12_._y -= 12;
  183.          _loc6_.tf.htmlText = "";
  184.       }
  185.       else
  186.       {
  187.          _loc3_.htmlText = "";
  188.       }
  189.       _loc16_ = {mc:_loc6_,h:_loc14_,w:_loc15_};
  190.       return _loc16_;
  191.    }
  192.    function splitString(i)
  193.    {
  194.       this.textArray = [];
  195.       var _loc10_ = this.dataObj.software.contentList[i].information;
  196.       var _loc6_ = _loc10_.split("<p>");
  197.       var _loc9_ = "";
  198.       i = 0;
  199.       while(i < _loc6_.length)
  200.       {
  201.          if(_loc10_[i] != "<p>")
  202.          {
  203.             _loc9_ += _loc6_[i];
  204.          }
  205.          i = i + 1;
  206.       }
  207.       _loc6_ = _loc9_.split("</p>");
  208.       _loc9_ = "";
  209.       i = 0;
  210.       while(i < _loc6_.length)
  211.       {
  212.          if(_loc10_[i] != "</p>")
  213.          {
  214.             _loc9_ += _loc6_[i];
  215.          }
  216.          i = i + 1;
  217.       }
  218.       var _loc11_ = _loc9_.split("<li>");
  219.       var _loc2_ = 0;
  220.       var _loc5_ = 0;
  221.       while(_loc5_ < _loc11_.length)
  222.       {
  223.          var _loc3_ = _loc11_[_loc5_];
  224.          var _loc7_ = _loc3_.indexOf("</li>");
  225.          if(_loc7_ == -1)
  226.          {
  227.             this.textArray[_loc2_] = {type:"text",data:"<p>" + _loc3_ + "</p>"};
  228.             _loc2_ = _loc2_ + 1;
  229.          }
  230.          else if(_loc7_ <= _loc3_.length - 7)
  231.          {
  232.             var _loc8_ = _loc3_.split("</li>");
  233.             this.textArray[_loc2_] = {type:"list",data:"<p class=\'text\'>" + _loc8_[0] + "</p>"};
  234.             _loc2_ = _loc2_ + 1;
  235.             this.textArray[_loc2_] = {type:"text",data:"<p>" + _loc8_[1] + "</p>"};
  236.             _loc2_ = _loc2_ + 1;
  237.          }
  238.          else
  239.          {
  240.             _loc8_ = _loc3_.split("</li>");
  241.             this.textArray[_loc2_] = {type:"list",data:"<p class=\'text\'>" + _loc8_[0] + "</p>"};
  242.             _loc2_ = _loc2_ + 1;
  243.          }
  244.          _loc5_ = _loc5_ + 1;
  245.       }
  246.    }
  247. }
  248.