home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FCE Gold Plus
/
GOLD.iso
/
pc
/
shell.swf
/
scripts
/
__Packages
/
com
/
screen
/
DropDown.as
< prev
next >
Wrap
Text File
|
2007-10-16
|
22KB
|
638 lines
class com.screen.DropDown
{
var iLineSp = 22;
var iLevel = 1;
var btnNo = 0;
var tempID = 9;
function DropDown()
{
}
function init(_objRef, _objSection, _wth, x, y, _mcName, _type, _group, _navRef)
{
var _loc1_ = this;
var _loc2_ = _objSection;
_loc1_.objRef = _objRef;
_loc1_.c_objSection = _loc2_;
_loc1_.strTitle = _loc1_.getTitle(_loc2_);
_loc1_.strText = _loc1_.getText(_loc2_);
_loc1_.strHeaderTxt = _loc1_.getHeaderText(_loc2_);
_loc1_.iWidth = _wth;
_loc1_.xLoc = x;
_loc1_.yLoc = y;
_loc1_.c_strAthMC = _mcName;
_loc1_.c_strType = _type;
_loc1_.c_iGroup = _group;
_loc1_.c_objNavRef = _navRef;
_loc1_.c_objRefPoi = _loc1_.getRefTest(_loc2_);
_loc1_.c_strMode = _loc1_.c_objNavRef.c_objTestRef.c_strMode;
_loc1_.c_strSkill = _loc1_.c_objNavRef.c_objTestRef.c_strSkill;
_loc1_.c_objHMObj = _loc1_.c_objNavRef.c_objTestRef.c_hQuestionState;
_loc1_.startProcess();
}
function startProcess()
{
var _loc1_ = this;
var _loc2_ = _loc1_.c_objSection.question;
var objRefPoints = _loc1_.c_objSection.ReferencePoints;
var _loc3_ = _loc1_.objRef.mc_ScrollSize._width;
var iScrollSizeHeight = _loc1_.objRef.mc_ScrollSize._height;
var iScrollSizeX = _loc1_.objRef.mc_ScrollSize._x;
var iScrollSizeY = _loc1_.objRef.mc_ScrollSize._y;
_loc1_.objRef.mc_ParagraphSP.setScrollContent("SP_content_con");
_loc1_.objRef.createEmptyMovieClip("fib",_loc1_.iLevel);
_loc1_.objRef.mc_ParagraphSP.setSize(_loc3_ - 1,iScrollSizeHeight - 1);
_loc1_.objRef.mc_ParagraphSP._x = iScrollSizeX;
_loc1_.objRef.mc_ParagraphSP._y = iScrollSizeY;
_loc1_.fib = _loc1_.objRef.mc_ParagraphSP.getScrollContent();
_loc1_.fib._x = _loc1_.xLoc;
_loc1_.fib._y = _loc1_.yLoc;
_loc1_.displayTitle(_loc3_);
if(_loc1_.strHeaderTxt != null || _loc1_.strHeaderTxt != undefined || _loc1_.strHeaderTxt != "")
{
_loc1_.displayHeaderText();
}
_loc1_.displayText();
_loc1_.fillComboData(_loc1_.fib,_loc2_);
_loc1_.setComboValues(_loc2_);
_loc1_.displaySelectionClip(_loc1_.fib);
_loc1_.objRef.mc_ParagraphSP.refreshPane();
_loc1_.showReferenceSection(objRefPoints);
}
function showReferenceSection(objRefPoints)
{
var _loc1_ = this;
_loc1_.objRef.mc_SPMCQ5.setScrollContent("SP_content_con");
_loc1_.objRefContainer = _loc1_.objRef.mc_SPMCQ5.getScrollContent();
_loc1_.objRef.mc_SPMCQ5.setSize(_loc1_.objRef.mc_RefScrollSize._width,_loc1_.objRef.mc_RefScrollSize._height);
_loc1_.objRef.mc_SPMCQ5._x = _loc1_.objRef.mc_RefScrollSize._x;
_loc1_.objRef.mc_SPMCQ5._y = _loc1_.objRef.mc_RefScrollSize._y;
_loc1_.showReferenceText(_loc1_.objRefContainer,objRefPoints);
_loc1_.showFeedback(false);
_loc1_.objRef.mc_SPMCQ5.refreshPane();
}
function displayTitle()
{
var _loc3_ = this;
var iTitleWidth = _loc3_.objRef.mc_ParagraphSP._width;
_loc3_.fib.createTextField("title",10000,0,0,iTitleWidth,20);
var _loc1_ = _loc3_.fib.title;
var strEnvironment = com.controller.UICoordinator.getInstance().getOSEnvironment();
var _loc2_ = new TextFormat();
_loc2_.font = "Verdana";
_loc2_.size = 11;
_loc2_.color = "0x000000";
if(strEnvironment == "Linux")
{
_loc1_.embedFonts = true;
}
_loc1_.html = true;
_loc1_.autoSize = true;
_loc1_.htmlText = _loc3_.strTitle;
_loc1_.selectable = false;
_loc1_.autoSize = "left";
_loc1_.setTextFormat(_loc2_);
false;
delete strEnvironment;
}
function displayHeaderText()
{
var _loc3_ = this;
var iHeaderTxtWidth = _loc3_.objRef.mc_ParagraphSP._width;
var iHeaderY = _loc3_.fib.title._y + 10;
_loc3_.fib.createTextField("headerTxt",10005,15,13,370,20);
var _loc1_ = _loc3_.fib.headerTxt;
var strEnvironment = com.controller.UICoordinator.getInstance().getOSEnvironment();
var _loc2_ = new TextFormat();
_loc2_.font = "Verdana";
_loc2_.size = 11;
_loc2_.color = "0x000000";
if(strEnvironment == "Linux")
{
_loc1_.embedFonts = true;
}
_loc1_.html = true;
_loc1_.multiline = true;
_loc1_.wordWrap = true;
_loc1_.htmlText = _loc3_.strHeaderTxt;
_loc1_.selectable = false;
_loc1_.autoSize = true;
_loc1_.text.align = "center";
_loc1_.setTextFormat(_loc2_);
false;
delete strEnvironment;
}
function displayText()
{
var _loc1_ = this;
_loc1_.c_arrQuesNos = new Array();
var arrData = _loc1_.arrangetext();
var iMC_Width = 7;
var iMC_X = 0;
var iMC_Y = _loc1_.fib.title._y + _loc1_.fib.title._height + 10;
var strEnvironment = com.controller.UICoordinator.getInstance().getOSEnvironment();
var objTF = new TextFormat();
objTF.font = "Verdana";
objTF.size = 11;
var mcComboHolder = _loc1_.fib.createEmptyMovieClip("mcComboHolder",1);
var mcTextFieldHolder = _loc1_.fib.createEmptyMovieClip("mcTextFieldHolder",2);
var i = 0;
while(i < arrData.length)
{
var strText = arrData[i];
if(i % 2 == 1)
{
if(strText != "")
{
var _loc3_ = _loc1_.fib.attachMovie(_loc1_.c_strAthMC,"Box" + _loc1_.btnNo,i);
_loc1_.c_arrQuesNos.push(strText);
_loc3_._x = iMC_X;
_loc3_._y = iMC_Y;
_loc3_.setSize(45,22);
_loc3_.strCorrectAnswer = _loc1_.getCorrectAnswer(_loc1_.btnNo);
_loc3_.queNumber = _loc1_.getQueNo(_loc1_.btnNo);
_loc3_.answered = "no";
var iBoxWith = _loc3_._width;
iMC_X += iBoxWith;
iMC_Width += iBoxWith;
if(iMC_X > _loc1_.iWidth)
{
iMC_X = iBoxWith;
iMC_Width = iBoxWith;
iMC_Y += _loc1_.iLineSp;
_loc3_._x = 7;
_loc3_._y = iMC_Y;
}
_loc1_.addEventToDropDown(_loc3_,_loc1_.objRef);
_loc1_.btnNo = _loc1_.btnNo + 1;
}
}
else if(i % 2 == 0)
{
var arrTmp = strText.split(" ");
var tmpWidth = iMC_Width;
var strNewLine = false;
_loc1_.fib.createTextField("text" + i,i,iMC_X,iMC_Y,10,20);
var _loc2_ = _loc1_.fib["text" + i];
_loc2_.text = "";
var objOutput = _loc1_.populateText(arrTmp,_loc2_,objTF,iMC_Width,tmpWidth,strNewLine,strEnvironment);
strNewLine = objOutput.strNewLine;
var j = objOutput.j;
iMC_Width = objOutput.iMC_Width;
_loc2_.text = _loc2_.text.substr(0,_loc2_.text.length - 1);
_loc2_.autoSize = true;
_loc2_.multiline = true;
var strTmp = "";
arrData = _loc1_.updateTextField(j,arrTmp,strTmp,strNewLine,_loc2_,arrData,i,strEnvironment);
if(strEnvironment == "Linux")
{
_loc2_.embedFonts = true;
}
delete j;
_loc2_._width = 10;
_loc2_.html = true;
_loc2_.htmlText = _loc2_.text;
_loc2_.multiline = true;
_loc2_.autoSize = true;
_loc2_.setTextFormat(objTF);
iMC_X += _loc2_._width;
if(iMC_Width > _loc1_.iWidth || strNewLine)
{
iMC_X = 7;
iMC_Width = 0;
iMC_Y += _loc1_.iLineSp;
}
}
i++;
}
_loc1_.c_iDepth = arrData.length;
delete objTF;
}
function updateTextField(in_j, arrTmp, strTmp, strNewLine, tField, arrData, in_iIndex, strEnvironment)
{
var _loc1_ = in_j;
var _loc2_ = strTmp;
var _loc3_ = arrTmp;
_loc1_;
while(_loc1_ < _loc3_.length)
{
_loc2_ = _loc2_ + _loc3_[_loc1_] + " ";
_loc1_ = _loc1_ + 1;
}
_loc2_ = _loc2_.substr(0,_loc2_.length - 1);
if(_loc2_.length > 0)
{
if(strEnvironment == "Linux")
{
tField.embedFonts = true;
}
if(!strNewLine)
{
tField.text = tField.text.substr(0,tField.text.length - _loc2_.split(" ")[0].length);
}
else
{
tField.text = tField.text.substr(0,tField.text.length - 2);
}
arrData = this.updateArray(arrData,_loc2_,in_iIndex);
}
return arrData;
}
function populateText(arrTmp, tField, objTF, iMC_Width, tmpWidth, strNewLine, strEnvironment)
{
var _loc1_ = tField;
var _loc3_ = arrTmp;
var objOutput = new Object();
var _loc2_ = 0;
while(_loc2_ < _loc3_.length)
{
if(strEnvironment == "Linux")
{
_loc1_.embedFonts = true;
}
_loc1_.text = _loc1_.text + _loc3_[_loc2_] + " ";
_loc1_.type = "dynamic";
_loc1_.selectable = false;
_loc1_.setTextFormat(objTF);
_loc1_.autoSize = true;
_loc1_.multiline = true;
iMC_Width = tmpWidth + _loc1_._width;
if(iMC_Width > this.iWidth)
{
break;
}
if(_loc3_[_loc2_] == "<p></p>")
{
_loc2_ = _loc2_ + 1;
strNewLine = true;
break;
}
_loc2_ = _loc2_ + 1;
}
objOutput.j = _loc2_;
objOutput.strNewLine = strNewLine;
objOutput.iMC_Width = iMC_Width;
return objOutput;
}
function displaySelectionClip()
{
var iTotalQuestions = this.c_arrQuesNos.length;
var mcSelectionClipHolder = this.fib.createEmptyMovieClip("mcSelectionClipHolder",this.c_iDepth + 1);
var _loc1_ = 1;
while(_loc1_ <= iTotalQuestions)
{
var _loc2_ = mcSelectionClipHolder.attachMovie("mcComboSelection","mcSelectionRect_" + _loc1_,_loc1_);
var _loc3_ = this.fib["Box" + (_loc1_ - 1)];
_loc2_._x = _loc3_._x - 1;
_loc2_._y = _loc3_._y - 1;
_loc1_ = _loc1_ + 1;
}
this.deselectAllCombo();
}
function addEventToDropDown(box, objRef)
{
var _loc1_ = this;
box.objBoxCombo = new Object();
box.objBoxCombo.objRef = _loc1_;
box.onSetFocus = function()
{
box.pCustomFocus = true;
var _loc1_ = Number(box._name.substr(-1));
box.objBoxCombo.objRef.showComboSelection(_loc1_ + 1);
box.objBoxCombo.objRef.showNavigationSelection(_loc1_,this.objRef);
};
box.objBoxCombo.change = function(evt)
{
var _loc1_ = box.getSelectedIndex();
this.objRef.onComboChanged(box,this.objRef,_loc1_);
box.pCustomFocus = false;
};
box.setChangeHandler("change",box.objBoxCombo);
}
function showComboSelection(iBoxNumber)
{
this.deselectAllCombo();
this.fib.mcSelectionClipHolder["mcSelectionRect_" + iBoxNumber].gotoAndStop("_SELECT");
}
function showNavigationSelection(iBoxNumber, objRef)
{
var _loc1_ = this;
var _loc2_ = iBoxNumber;
_loc1_.fileNo = _loc2_;
_loc1_.c_objNavRef.c_iSeleID = _loc1_.c_arrQuesNos[_loc2_];
_loc1_.c_objNavRef.c_preSelecetd = _loc1_.c_objNavRef.c_strSelecetd;
_loc1_.c_objNavRef.c_strSelecetd = "_" + _loc1_.c_iGroup + "_" + _loc1_.fileNo;
_loc1_.objRef.txt_QuestionNo.text = _loc1_.c_objSection.question[_loc2_].attributes.number;
_loc1_.c_objNavRef.navClickedfunction();
}
function deselectAllCombo()
{
var _loc3_ = this;
var _loc2_ = _loc3_.c_arrQuesNos.length;
var _loc1_ = 1;
while(_loc1_ <= _loc2_)
{
_loc3_.fib.mcSelectionClipHolder["mcSelectionRect_" + _loc1_].gotoAndStop("_DESELECT");
_loc1_ = _loc1_ + 1;
}
}
function arrangetext()
{
this.strText = this.strText.split("<p></p>").join(" <p></p> ");
var _loc3_ = this.strText.split("<gap type=\'dropdown\'>");
var arrData = new Array();
arrData.push(_loc3_[0]);
var _loc1_ = 1;
while(_loc1_ < _loc3_.length)
{
var _loc2_ = _loc3_[_loc1_].split("</gap>");
arrData.push(_loc2_[0]);
arrData.push(_loc2_[1]);
false;
_loc1_ = _loc1_ + 1;
}
false;
false;
return arrData;
}
function updateArray(_arr, _str, _iPos)
{
var _loc2_ = _arr;
var _loc3_ = new Array();
var _loc1_ = undefined;
_loc1_ = 0;
while(_loc1_ < _iPos + 1)
{
_loc3_.push(_loc2_[_loc1_]);
_loc1_ = _loc1_ + 1;
}
_loc3_.push("");
_loc3_.push(_str);
_loc1_;
while(_loc1_ < _loc2_.length)
{
_loc3_.push(_loc2_[_loc1_]);
_loc1_ = _loc1_ + 1;
}
false;
false;
delete _str;
delete _iPos;
return _loc3_;
}
function onComboChanged(box, objRef, iSelectedIndex)
{
var _loc1_ = this;
if(box.pCustomFocus)
{
var _loc3_ = box._name.substr(-1);
var _loc2_ = new Object();
var _strCorrAns = Number(box.strCorrectAnswer) - 1;
box.answered = "yes";
_loc2_.attempted = iSelectedIndex;
if(iSelectedIndex == _strCorrAns)
{
_loc2_.correct = 1;
}
else
{
_loc2_.correct = 0;
}
_loc1_.c_objNavRef.c_objTestRef.c_strCurrSelected = _loc3_;
_loc1_.c_objNavRef.c_objTestRef.c_iCurrQuestion = _loc1_.c_objSection.question[_loc3_].attributes.number;
_loc1_.objRef.txt_QuestionNo.text = _loc1_.c_objSection.question[_loc3_].attributes.number;
_loc1_.c_objNavRef.markAttempted();
_loc1_.c_objNavRef.c_objTestRef.appendQuesObject(_loc2_);
_loc1_.showNextButton();
}
}
function showNextButton()
{
var _loc2_ = this;
if(_loc2_.c_objNavRef.c_objTestRef.c_objScreenData.DOC.section.length - 1 != _loc2_.c_objNavRef.c_objTestRef.c_iPartNo)
{
if(_loc2_.c_strMode == "Review")
{
_loc2_.objRef.btn_next._visible = true;
}
else
{
var _loc1_ = 0;
while(_loc1_ < _loc2_.c_arrQuesNos.length)
{
_loc2_.objRef.btn_next._visible = true;
if(_loc2_.fib["Box" + _loc1_].answered == "no")
{
_loc2_.objRef.btn_next._visible = false;
break;
}
_loc1_ = _loc1_ + 1;
}
}
}
}
function navBtnClicked(_iCurrQuestion)
{
var _loc1_ = this;
var _loc3_ = _iCurrQuestion;
var _loc2_ = _loc1_.c_strMode == "Review";
_loc1_.fileNo = _loc3_;
_loc1_.showNextButton();
_loc1_.showComboSelection(_loc3_ + 1);
_loc1_.freeze(_loc2_);
_loc1_.showFeedback(_loc2_);
_loc1_.setScrollBarPosition(_loc3_);
}
function setScrollBarPosition(_iCurrQuestion)
{
var _loc2_ = this.fib["Box" + _iCurrQuestion];
var boxTargetX = _loc2_._x;
var _loc1_ = _loc2_._y;
if(_iCurrQuestion == 0)
{
_loc1_ = 0;
}
else
{
_loc1_ -= 75;
}
this.objRef.mc_ParagraphSP.setScrollPosition(0,_loc1_);
}
function freeze(_blnFreeze)
{
var _loc2_ = this;
var _loc3_ = _blnFreeze;
var _loc1_ = 0;
while(_loc1_ < _loc2_.c_arrQuesNos.length)
{
_loc2_.fib["Box" + _loc1_].enabled = !_loc3_;
_loc1_ = _loc1_ + 1;
}
}
function showFeedback(_bIfReview)
{
var _loc1_ = this;
_loc1_.hideAllFeedback();
if(_bIfReview)
{
var strCorrectID = _loc1_.getCorrectAnswer(_loc1_.fileNo);
var strQuestionID = _loc1_.getQueNo(_loc1_.fileNo);
var _loc2_ = _loc1_.c_objHMObj["get"](String(_loc1_.c_strSkill + "_" + strQuestionID));
var _loc3_ = Number(_loc2_.attempted);
if(_loc2_.correct == "0")
{
_loc1_.objRefContainer["mc_TickCross_" + (_loc3_ + 1)].gotoAndStop("INCORRECT");
}
_loc1_.objRefContainer["mc_TickCross_" + strCorrectID].gotoAndStop("CORRECT");
}
}
function hideAllFeedback()
{
var _loc3_ = this;
var _loc2_ = _loc3_.c_objSection.ReferencePoints.point.length;
var _loc1_ = 0;
while(_loc1_ < _loc2_)
{
_loc3_.objRefContainer["mc_TickCross_" + (_loc1_ + 1)].gotoAndStop("BLANK");
_loc1_ = _loc1_ + 1;
}
}
function fillComboData(objScrollContent, arrQuestions)
{
var _loc3_ = arrQuestions;
var iQueLen = _loc3_.length;
var _loc1_ = 0;
while(_loc1_ < iQueLen)
{
var arrComboData = new Array();
var queTextNo = _loc3_[_loc1_].attributes.number;
var queTextCorrectAns = _loc3_[_loc1_].attributes.correct;
var queTextChoicesLen = _loc3_[_loc1_].choices.choice.length;
var queNumber = _loc3_[_loc1_].attributes.number;
var _loc2_ = 0;
while(_loc2_ < queTextChoicesLen)
{
var queData = _loc3_[_loc1_].choices.choice[_loc2_].data;
var queID = _loc3_[_loc1_].choices.choice[_loc2_].attributes.id;
arrComboData.push({label:queData,data:queID});
_loc2_ = _loc2_ + 1;
}
objScrollContent["Box" + _loc1_].setDataProvider(arrComboData);
_loc1_ = _loc1_ + 1;
}
}
function setComboValues(arrQuestions)
{
var _loc3_ = this;
_level101.txt_Tracer1.text += "";
_level101.txt_Tracer1.text += "\n Inside - setComboValues";
_level101.txt_Tracer1.text += "\n arrQuestions.length : " + arrQuestions.length;
var _loc1_ = 0;
while(_loc1_ < arrQuestions.length)
{
var strQuestionID = arrQuestions[_loc1_].attributes.number;
_level101.txt_Tracer1.text += "\n Inside Loop strQuestionID : " + strQuestionID;
var _loc2_ = _loc3_.c_objHMObj["get"](String(_loc3_.c_strSkill + "_" + strQuestionID));
_level101.txt_Tracer1.text += "\n objHMObject : " + _loc2_;
if(_loc2_.attempted != null || _loc2_.attempted != undefined)
{
_loc3_.fib["Box" + _loc1_].answered = "yes";
_loc3_.fib["Box" + _loc1_].setSelectedIndex(_loc2_.attempted);
}
else
{
_level101.txt_Tracer1.text += "\n objHMObject.attempted == null or undefined or blank";
_loc3_.fib["Box" + _loc1_].setSelectedIndex(_loc2_.attempted);
}
_loc1_ = _loc1_ + 1;
}
}
function showReferenceText(mcScrollContent, objRefPoints)
{
var _loc3_ = mcScrollContent;
_loc3_.txt_RefText.htmlText = true;
var iTotalRefPoints = objRefPoints.point.length;
var iRPtext_xpos;
var iRPtext_ypos;
var iPlace;
var _loc2_ = 1;
while(_loc2_ <= iTotalRefPoints)
{
var strRefText = objRefPoints.point[_loc2_ - 1].text.data;
var strRefId = objRefPoints.point[_loc2_ - 1].id.data;
var _loc1_ = _loc3_.attachMovie("mc_RefText","mc_RefText_" + _loc2_,_loc2_);
_loc1_.txt_RefText.autoSize = true;
_loc1_.txt_RefText.multiline = true;
_loc1_.txt_RefText.autoSize = true;
_loc1_.txt_RefText.html = true;
_loc1_.txt_RefText.htmlText = strRefText;
_loc1_.txt_RefTextID.autoSize = true;
_loc1_.txt_RefTextID.html = true;
_loc1_.txt_RefTextID.htmlText = strRefId;
iPlace += _loc3_["mc_RefText_" + (_loc2_ - 1)].txt_RefText._y + _loc3_["mc_RefText_" + (_loc2_ - 1)]._height - 25;
_loc1_._y = iPlace;
var mcTickCross = _loc3_.attachMovie("mc_TickCrossL","mc_TickCross_" + _loc2_,950 + _loc2_);
mcTickCross._x = _loc1_._x + _loc1_._width + 1;
mcTickCross._y = _loc1_._y + 13;
_loc2_ = _loc2_ + 1;
}
var objResizeBox = new com.comp.ResizableBox();
var iHeaderHeight = objResizeBox.getHeaderHeight(this.objRef.mc_textcont);
var iHeight = iHeaderHeight + this.objRef.mc_RefScrollSize._height + 1;
var iWidth = this.objRef.mc_RefScrollSize._width;
objResizeBox.resizeBox(iWidth,iHeight,this.objRef.mc_textcont);
}
function getTitle(objSection)
{
var _loc1_ = undefined;
_loc1_ = objSection.title.data;
return _loc1_;
}
function getHeaderText(objSection)
{
var _loc1_ = undefined;
_loc1_ = objSection.headerText.data;
return _loc1_;
}
function getText(objSection)
{
var _loc1_ = undefined;
_loc1_ = objSection.text.data;
return _loc1_;
}
function getRefTest(objSection)
{
var _loc1_ = undefined;
_loc1_ = objSection.ReferencePoints;
return _loc1_;
}
function getCorrectAnswer(iComboNo)
{
var _loc2_ = this.c_objSection.question;
var queLength = _loc2_.length;
var _loc1_ = 0;
while(_loc1_ <= queLength)
{
if(_loc2_[_loc1_] == _loc2_[iComboNo])
{
var _loc3_ = _loc2_[_loc1_].attributes.correct;
return _loc3_;
}
_loc1_ = _loc1_ + 1;
}
}
function getQueNo(iComboNo)
{
var _loc2_ = this.c_objSection.question;
var _loc1_ = 0;
while(_loc1_ <= _loc2_.length)
{
if(_loc2_[_loc1_] == _loc2_[iComboNo])
{
var _loc3_ = _loc2_[_loc1_].attributes.number;
return _loc3_;
}
_loc1_ = _loc1_ + 1;
}
}
}