home *** CD-ROM | disk | FTP | other *** search
/ FCE Gold Plus / GOLD.iso / pc / shell.swf / scripts / __Packages / com / comp / WordWrap.as < prev   
Text File  |  2007-10-16  |  6KB  |  184 lines

  1. class com.comp.WordWrap
  2. {
  3.    var c_iLevel = 1;
  4.    function WordWrap()
  5.    {
  6.    }
  7.    function init(_obj, _tit, _txt, x, y, _wdth)
  8.    {
  9.       var _loc1_ = this;
  10.       _loc1_.c_objRef = _obj;
  11.       _loc1_.c_strTitle = _tit;
  12.       _loc1_.c_strText = _txt;
  13.       _loc1_.c_iWidth = _wdth;
  14.       _loc1_.c_strImgPath = "tests/test" + com.controller.UICoordinator.getInstance().currentTestNumber + "/jpegs/";
  15.       _loc1_.startProcess(x,y);
  16.    }
  17.    function startProcess(iX, iy)
  18.    {
  19.       var _loc1_ = this;
  20.       _loc1_.c_main = _loc1_.c_objRef.createEmptyMovieClip("mainCont",_loc1_.c_iLevel);
  21.       _loc1_.c_mask = _loc1_.c_objRef.attachMovie("mc_mask","mc_mask",_loc1_.c_iLevel + 1);
  22.       _loc1_.c_main._x = _loc1_.c_mask._x = iX;
  23.       _loc1_.c_main._y = _loc1_.c_mask._y = iy;
  24.       _loc1_.c_mask._width = _loc1_.c_iWidth;
  25.       _loc1_.c_mask._height = 336;
  26.       _loc1_.displayTitle();
  27.       _loc1_.loadText();
  28.       if(_loc1_.c_strText.split("<image>").length > 1)
  29.       {
  30.          _loc1_.c_iYPos = 30 + _loc1_.c_main.txt._height;
  31.          _loc1_.c_imgNo = 0;
  32.          _loc1_.loadImages();
  33.       }
  34.       _loc1_.c_objRef.mainCont.setMask(_loc1_.c_objRef.mc_mask);
  35.    }
  36.    function displayTitle()
  37.    {
  38.       var _loc3_ = this;
  39.       _loc3_.c_main.createTextField("title",500,0,0,_loc3_.c_iWidth,25);
  40.       var _loc2_ = _loc3_.c_main.title;
  41.       var _loc1_ = new TextFormat();
  42.       _loc1_.font = "Verdana";
  43.       _loc1_.size = 11;
  44.       _loc1_.color = "0x000000";
  45.       _loc2_.html = true;
  46.       _loc2_.htmlText = "<p align=\'center\'><b>" + _loc3_.c_strTitle + "</b></p>";
  47.       _loc2_.selectable = false;
  48.       _loc2_.setTextFormat(_loc1_);
  49.       false;
  50.    }
  51.    function loadText()
  52.    {
  53.       var _loc3_ = this;
  54.       _loc3_.c_main.createTextField("txt",1,0,30,_loc3_.c_iWidth,10);
  55.       var _loc1_ = _loc3_.c_main.txt;
  56.       var _loc2_ = new TextFormat();
  57.       _loc2_.font = "Verdana";
  58.       _loc2_.size = 11;
  59.       _loc2_.color = "0x000000";
  60.       _loc1_.html = true;
  61.       _loc1_.htmlText = _loc3_.c_strText.split("<image>")[0];
  62.       _loc1_.multiline = true;
  63.       _loc1_.wordWrap = true;
  64.       _loc1_.autoSize = true;
  65.       _loc1_.selectable = false;
  66.       _loc1_.setTextFormat(_loc2_);
  67.       false;
  68.       _loc3_.getHeight();
  69.    }
  70.    function loadImages()
  71.    {
  72.       var _loc1_ = this;
  73.       var arrData = _loc1_.arrangetext();
  74.       var _loc3_ = _loc1_.c_main.createEmptyMovieClip("image" + _loc1_.c_imgNo,_loc1_.c_imgNo);
  75.       _loc3_.createEmptyMovieClip("imgHolder",1);
  76.       _loc3_.imgHolder.loadMovie(_loc1_.c_strImgPath + arrData[_loc1_.c_imgNo]);
  77.       _loc3_._y = _loc1_.c_iYPos;
  78.       _loc3_.objRef = _loc1_;
  79.       _loc3_.onEnterFrame = function()
  80.       {
  81.          var _loc1_ = this;
  82.          if(_loc1_._width > 0)
  83.          {
  84.             var _loc2_ = _loc1_._name.substr(5,_loc1_._name.length);
  85.             arrData[_loc2_] = arrData[_loc2_] + " " + _loc1_._width + " " + _loc1_._height;
  86.             delete _loc1_.onEnterFrame;
  87.             var strData = arrData[Number(_loc2_) + 1];
  88.             var iWidth = arrData[_loc2_].split(" ")[1];
  89.             var _loc3_ = arrData[_loc2_].split(" ")[2];
  90.             _loc1_.objRef.showCorrText(strData,iWidth,_loc3_);
  91.          }
  92.       };
  93.    }
  94.    function showCorrText(_strData, _iWidth, _iHeight)
  95.    {
  96.       var _loc3_ = this;
  97.       var iXPos = Number(_iWidth) + 8;
  98.       var iHeight = Number(_iHeight) + 8;
  99.       var iTxtNo = Number(_loc3_.c_imgNo) + 1;
  100.       _loc3_.c_main.createTextField("txt" + iTxtNo,iTxtNo + 2,iXPos,_loc3_.c_iYPos,_loc3_.c_iWidth - iXPos,10);
  101.       var txt = _loc3_.c_main["txt" + iTxtNo];
  102.       txt.text = "";
  103.       txt.multiline = true;
  104.       txt.wordWrap = true;
  105.       txt.selectable = false;
  106.       var objTF = new TextFormat();
  107.       objTF.font = "Verdana";
  108.       objTF.size = 11;
  109.       objTF.color = "0x000000";
  110.       var _loc2_ = _strData.split(" ");
  111.       var _loc1_ = 0;
  112.       while(_loc1_ < _loc2_.length)
  113.       {
  114.          txt.text = txt.text + _loc2_[_loc1_] + " ";
  115.          txt.setTextFormat(objTF);
  116.          txt.autoSize = true;
  117.          if(txt._height > iHeight)
  118.          {
  119.             txt.text = txt.text.substr(0,txt.text.length - _loc2_[_loc1_].length - 1);
  120.             break;
  121.          }
  122.          _loc1_ = _loc1_ + 1;
  123.       }
  124.       txt.html = true;
  125.       txt.htmlText = txt.text;
  126.       txt.setTextFormat(objTF);
  127.       _loc3_.c_iYPos += iHeight;
  128.       var strLeft = "";
  129.       _loc1_;
  130.       while(_loc1_ < _loc2_.length)
  131.       {
  132.          strLeft = strLeft + _loc2_[_loc1_] + " ";
  133.          _loc1_ = _loc1_ + 1;
  134.       }
  135.       if(strLeft.length > 0)
  136.       {
  137.          _loc3_.c_main.createTextField("txt" + iTxtNo + "_2",50 + iTxtNo,0,_loc3_.c_iYPos,_loc3_.c_iWidth,10);
  138.          var txt = _loc3_.c_main["txt" + iTxtNo + "_2"];
  139.          txt.multiline = true;
  140.          txt.wordWrap = true;
  141.          txt.html = true;
  142.          txt.htmlText = strLeft;
  143.          txt.selectable = false;
  144.          txt.setTextFormat(objTF);
  145.          txt.autoSize = true;
  146.          _loc3_.c_iYPos += txt._height;
  147.       }
  148.       false;
  149.       delete objTF;
  150.       _loc3_.c_imgNo += 2;
  151.       if(_loc3_.c_imgNo < _loc3_.arrangetext().length)
  152.       {
  153.          _loc3_.loadImages();
  154.       }
  155.       else
  156.       {
  157.          _loc3_.getHeight();
  158.       }
  159.    }
  160.    function arrangetext()
  161.    {
  162.       var _loc3_ = this.c_strText.split("<image>");
  163.       var arrData = new Array();
  164.       var _loc1_ = 1;
  165.       while(_loc1_ < _loc3_.length)
  166.       {
  167.          var _loc2_ = _loc3_[_loc1_].split("</image>");
  168.          arrData.push(_loc2_[0]);
  169.          arrData.push(_loc2_[1]);
  170.          false;
  171.          _loc1_ = _loc1_ + 1;
  172.       }
  173.       false;
  174.       false;
  175.       return arrData;
  176.    }
  177.    function getHeight()
  178.    {
  179.       var _loc1_ = new com.comp.ScrollBar(this.c_objRef,"mc_BoundingBox","mainCont",12,338);
  180.       _loc1_.setX(1);
  181.       return this.c_objRef.mainCont._height;
  182.    }
  183. }
  184.