home *** CD-ROM | disk | FTP | other *** search
- class com.comp.Fib extends MovieClip
- {
- var objRef;
- function Fib(_objRef, _strSourceClip, _strRollClip, _strInOutTxt, _strCorrAns)
- {
- var _loc1_ = this;
- super();
- _loc1_.c_ObjRef = _objRef;
- _loc1_.c_mcSourceClip = _objRef[_strSourceClip];
- _loc1_.c_mcRolloverClip = _loc1_.c_mcSourceClip[_strRollClip];
- _loc1_.c_txtInOut = _loc1_.c_mcSourceClip[_strInOutTxt];
- _loc1_.c_strCorrAns = _strCorrAns;
- _loc1_.c_ObjRef.attachMovie("btnNext","_mcNext",200);
- _loc1_.c_mcNext = _loc1_.c_ObjRef._mcNext;
- _loc1_.init();
- }
- function init()
- {
- var _loc1_ = this;
- _loc1_.c_mcSourceClip._x = Stage.width / 2;
- _loc1_.c_mcSourceClip._y = Stage.height / 2;
- _loc1_.c_mcNext._x = 400;
- _loc1_.c_mcNext._y = 300;
- _loc1_.c_mcNext._visible = false;
- _loc1_.textFormat();
- _loc1_.initText();
- _loc1_.setEvents();
- }
- function initText()
- {
- var _loc1_ = this;
- _loc1_.c_txtInOut.type = "Dynamic";
- _loc1_.c_txtInOut.setTextFormat(_loc1_.c_initTextFormat);
- }
- function clickedText()
- {
- var _loc1_ = this;
- _loc1_.c_txtInOut.setTextFormat(_loc1_.c_clickedTextFormat);
- Selection.setFocus(_loc1_.c_txtInOut);
- _loc1_.c_txtInOut.type = "Input";
- _loc1_.c_txtInOut.selectable = true;
- _loc1_.c_txtInOut.border = true;
- if(_loc1_.c_blnNextClicked)
- {
- Selection.setSelection(0,_loc1_.c_txtInOut.length);
- }
- else
- {
- _loc1_.c_txtInOut.text = "";
- }
- }
- function clickedNext(_tempRef)
- {
- var _loc1_ = _tempRef;
- _loc1_.c_txtInOut.setTextFormat(_loc1_.c_initTextFormat);
- Selection.setFocus();
- _loc1_.c_txtInOut.type = "Dynamic";
- _loc1_.c_txtInOut.selectable = false;
- _loc1_.c_txtInOut.border = false;
- }
- function funKeypressed(_tempRef)
- {
- var _loc1_ = this;
- if(_tempRef.c_txtInOut.text == "" || _loc1_.c_txtInOut == null || _loc1_.c_txtInOut == undefined)
- {
- _loc1_.c_mcNext._visible = false;
- }
- else
- {
- _loc1_.c_mcNext._visible = true;
- }
- }
- function textFormat()
- {
- var _loc1_ = this;
- _loc1_.c_initTextFormat = new TextFormat();
- _loc1_.c_initTextFormat.font = "Tahoma";
- _loc1_.c_initTextFormat.size = 12;
- _loc1_.c_initTextFormat.color = 102;
- _loc1_.c_initTextFormat.align = "center";
- _loc1_.c_initTextFormat.bold = true;
- _loc1_.c_clickedTextFormat = new TextFormat();
- _loc1_.c_clickedTextFormat.font = "Tahoma";
- _loc1_.c_clickedTextFormat.size = 12;
- _loc1_.c_clickedTextFormat.color = 0;
- _loc1_.c_clickedTextFormat.align = "left";
- _loc1_.c_clickedTextFormat.bold = false;
- }
- function setEvents()
- {
- var _loc1_ = this;
- _loc1_.c_mcSourceClip.objRef = _loc1_;
- var tempRef = _loc1_;
- _loc1_.c_mcSourceClip.onRollOver = function()
- {
- this.objRef.c_mcRolloverClip.gotoAndStop("white");
- };
- _loc1_.c_mcSourceClip.onRollOut = function()
- {
- this.objRef.c_mcRolloverClip.gotoAndStop("blue");
- };
- _loc1_.c_mcSourceClip.onRelease = function()
- {
- this.gotoAndStop("inp");
- Key.addListener(Key_listener);
- this.objRef.clickedText();
- };
- _loc1_.c_mcNext.onRelease = function()
- {
- tempRef.c_mcSourceClip.gotoAndStop("dyn");
- tempRef.c_blnNextClicked = true;
- tempRef.clickedNext(tempRef);
- Key.removeListener(Key_listener);
- tempRef.checkAns(tempRef);
- };
- var Key_listener = new Object();
- Key_listener.onKeyUp = function()
- {
- tempRef.funKeypressed(tempRef);
- };
- }
- function checkAns(_tempRef)
- {
- var _loc2_ = _tempRef;
- _loc2_.c_arrCorrAns = _loc2_.c_strCorrAns.split(",");
- var arrLength = _loc2_.c_arrCorrAns.length;
- var _loc3_ = false;
- var _loc1_ = 0;
- while(_loc1_ < arrLength)
- {
- trace(_loc2_.c_arrCorrAns[_loc1_]);
- if(_loc2_.c_txtInOut.text == _loc2_.c_arrCorrAns[_loc1_])
- {
- _loc3_ = true;
- break;
- }
- _loc3_ = false;
- _loc1_ = _loc1_ + 1;
- }
- if(_loc3_)
- {
- trace("correct ans");
- }
- else
- {
- trace("wrong ans");
- }
- }
- }
-