home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FCE Gold Plus
/
GOLD.iso
/
pc
/
shell.swf
/
scripts
/
__Packages
/
com
/
comp
/
WordWrap.as
< prev
Wrap
Text File
|
2007-10-16
|
6KB
|
184 lines
class com.comp.WordWrap
{
var c_iLevel = 1;
function WordWrap()
{
}
function init(_obj, _tit, _txt, x, y, _wdth)
{
var _loc1_ = this;
_loc1_.c_objRef = _obj;
_loc1_.c_strTitle = _tit;
_loc1_.c_strText = _txt;
_loc1_.c_iWidth = _wdth;
_loc1_.c_strImgPath = "tests/test" + com.controller.UICoordinator.getInstance().currentTestNumber + "/jpegs/";
_loc1_.startProcess(x,y);
}
function startProcess(iX, iy)
{
var _loc1_ = this;
_loc1_.c_main = _loc1_.c_objRef.createEmptyMovieClip("mainCont",_loc1_.c_iLevel);
_loc1_.c_mask = _loc1_.c_objRef.attachMovie("mc_mask","mc_mask",_loc1_.c_iLevel + 1);
_loc1_.c_main._x = _loc1_.c_mask._x = iX;
_loc1_.c_main._y = _loc1_.c_mask._y = iy;
_loc1_.c_mask._width = _loc1_.c_iWidth;
_loc1_.c_mask._height = 336;
_loc1_.displayTitle();
_loc1_.loadText();
if(_loc1_.c_strText.split("<image>").length > 1)
{
_loc1_.c_iYPos = 30 + _loc1_.c_main.txt._height;
_loc1_.c_imgNo = 0;
_loc1_.loadImages();
}
_loc1_.c_objRef.mainCont.setMask(_loc1_.c_objRef.mc_mask);
}
function displayTitle()
{
var _loc3_ = this;
_loc3_.c_main.createTextField("title",500,0,0,_loc3_.c_iWidth,25);
var _loc2_ = _loc3_.c_main.title;
var _loc1_ = new TextFormat();
_loc1_.font = "Verdana";
_loc1_.size = 11;
_loc1_.color = "0x000000";
_loc2_.html = true;
_loc2_.htmlText = "<p align=\'center\'><b>" + _loc3_.c_strTitle + "</b></p>";
_loc2_.selectable = false;
_loc2_.setTextFormat(_loc1_);
false;
}
function loadText()
{
var _loc3_ = this;
_loc3_.c_main.createTextField("txt",1,0,30,_loc3_.c_iWidth,10);
var _loc1_ = _loc3_.c_main.txt;
var _loc2_ = new TextFormat();
_loc2_.font = "Verdana";
_loc2_.size = 11;
_loc2_.color = "0x000000";
_loc1_.html = true;
_loc1_.htmlText = _loc3_.c_strText.split("<image>")[0];
_loc1_.multiline = true;
_loc1_.wordWrap = true;
_loc1_.autoSize = true;
_loc1_.selectable = false;
_loc1_.setTextFormat(_loc2_);
false;
_loc3_.getHeight();
}
function loadImages()
{
var _loc1_ = this;
var arrData = _loc1_.arrangetext();
var _loc3_ = _loc1_.c_main.createEmptyMovieClip("image" + _loc1_.c_imgNo,_loc1_.c_imgNo);
_loc3_.createEmptyMovieClip("imgHolder",1);
_loc3_.imgHolder.loadMovie(_loc1_.c_strImgPath + arrData[_loc1_.c_imgNo]);
_loc3_._y = _loc1_.c_iYPos;
_loc3_.objRef = _loc1_;
_loc3_.onEnterFrame = function()
{
var _loc1_ = this;
if(_loc1_._width > 0)
{
var _loc2_ = _loc1_._name.substr(5,_loc1_._name.length);
arrData[_loc2_] = arrData[_loc2_] + " " + _loc1_._width + " " + _loc1_._height;
delete _loc1_.onEnterFrame;
var strData = arrData[Number(_loc2_) + 1];
var iWidth = arrData[_loc2_].split(" ")[1];
var _loc3_ = arrData[_loc2_].split(" ")[2];
_loc1_.objRef.showCorrText(strData,iWidth,_loc3_);
}
};
}
function showCorrText(_strData, _iWidth, _iHeight)
{
var _loc3_ = this;
var iXPos = Number(_iWidth) + 8;
var iHeight = Number(_iHeight) + 8;
var iTxtNo = Number(_loc3_.c_imgNo) + 1;
_loc3_.c_main.createTextField("txt" + iTxtNo,iTxtNo + 2,iXPos,_loc3_.c_iYPos,_loc3_.c_iWidth - iXPos,10);
var txt = _loc3_.c_main["txt" + iTxtNo];
txt.text = "";
txt.multiline = true;
txt.wordWrap = true;
txt.selectable = false;
var objTF = new TextFormat();
objTF.font = "Verdana";
objTF.size = 11;
objTF.color = "0x000000";
var _loc2_ = _strData.split(" ");
var _loc1_ = 0;
while(_loc1_ < _loc2_.length)
{
txt.text = txt.text + _loc2_[_loc1_] + " ";
txt.setTextFormat(objTF);
txt.autoSize = true;
if(txt._height > iHeight)
{
txt.text = txt.text.substr(0,txt.text.length - _loc2_[_loc1_].length - 1);
break;
}
_loc1_ = _loc1_ + 1;
}
txt.html = true;
txt.htmlText = txt.text;
txt.setTextFormat(objTF);
_loc3_.c_iYPos += iHeight;
var strLeft = "";
_loc1_;
while(_loc1_ < _loc2_.length)
{
strLeft = strLeft + _loc2_[_loc1_] + " ";
_loc1_ = _loc1_ + 1;
}
if(strLeft.length > 0)
{
_loc3_.c_main.createTextField("txt" + iTxtNo + "_2",50 + iTxtNo,0,_loc3_.c_iYPos,_loc3_.c_iWidth,10);
var txt = _loc3_.c_main["txt" + iTxtNo + "_2"];
txt.multiline = true;
txt.wordWrap = true;
txt.html = true;
txt.htmlText = strLeft;
txt.selectable = false;
txt.setTextFormat(objTF);
txt.autoSize = true;
_loc3_.c_iYPos += txt._height;
}
false;
delete objTF;
_loc3_.c_imgNo += 2;
if(_loc3_.c_imgNo < _loc3_.arrangetext().length)
{
_loc3_.loadImages();
}
else
{
_loc3_.getHeight();
}
}
function arrangetext()
{
var _loc3_ = this.c_strText.split("<image>");
var arrData = new Array();
var _loc1_ = 1;
while(_loc1_ < _loc3_.length)
{
var _loc2_ = _loc3_[_loc1_].split("</image>");
arrData.push(_loc2_[0]);
arrData.push(_loc2_[1]);
false;
_loc1_ = _loc1_ + 1;
}
false;
false;
return arrData;
}
function getHeight()
{
var _loc1_ = new com.comp.ScrollBar(this.c_objRef,"mc_BoundingBox","mainCont",12,338);
_loc1_.setX(1);
return this.c_objRef.mainCont._height;
}
}