home *** CD-ROM | disk | FTP | other *** search
/ FCE Gold Plus / GOLD.iso / pc / fscommand / linux / main.swf / scripts / __Packages / com / comp / WordWrap.as < prev   
Encoding:
Text File  |  2007-09-06  |  5.9 KB  |  186 lines

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