home *** CD-ROM | disk | FTP | other *** search
/ FCE Gold Plus / GOLD.iso / pc / fscommand / assets / swfs / Fib.swf / scripts / __Packages / com / comp / Fib.as
Encoding:
Text File  |  2007-06-04  |  4.4 KB  |  150 lines

  1. class com.comp.Fib extends MovieClip
  2. {
  3.    var objRef;
  4.    function Fib(_objRef, _strSourceClip, _strRollClip, _strInOutTxt, _strCorrAns)
  5.    {
  6.       var _loc1_ = this;
  7.       super();
  8.       _loc1_.c_ObjRef = _objRef;
  9.       _loc1_.c_mcSourceClip = _objRef[_strSourceClip];
  10.       _loc1_.c_mcRolloverClip = _loc1_.c_mcSourceClip[_strRollClip];
  11.       _loc1_.c_txtInOut = _loc1_.c_mcSourceClip[_strInOutTxt];
  12.       _loc1_.c_strCorrAns = _strCorrAns;
  13.       _loc1_.c_ObjRef.attachMovie("btnNext","_mcNext",200);
  14.       _loc1_.c_mcNext = _loc1_.c_ObjRef._mcNext;
  15.       _loc1_.init();
  16.    }
  17.    function init()
  18.    {
  19.       var _loc1_ = this;
  20.       _loc1_.c_mcSourceClip._x = Stage.width / 2;
  21.       _loc1_.c_mcSourceClip._y = Stage.height / 2;
  22.       _loc1_.c_mcNext._x = 400;
  23.       _loc1_.c_mcNext._y = 300;
  24.       _loc1_.c_mcNext._visible = false;
  25.       _loc1_.textFormat();
  26.       _loc1_.initText();
  27.       _loc1_.setEvents();
  28.    }
  29.    function initText()
  30.    {
  31.       var _loc1_ = this;
  32.       _loc1_.c_txtInOut.type = "Dynamic";
  33.       _loc1_.c_txtInOut.setTextFormat(_loc1_.c_initTextFormat);
  34.    }
  35.    function clickedText()
  36.    {
  37.       var _loc1_ = this;
  38.       _loc1_.c_txtInOut.setTextFormat(_loc1_.c_clickedTextFormat);
  39.       Selection.setFocus(_loc1_.c_txtInOut);
  40.       _loc1_.c_txtInOut.type = "Input";
  41.       _loc1_.c_txtInOut.selectable = true;
  42.       _loc1_.c_txtInOut.border = true;
  43.       if(_loc1_.c_blnNextClicked)
  44.       {
  45.          Selection.setSelection(0,_loc1_.c_txtInOut.length);
  46.       }
  47.       else
  48.       {
  49.          _loc1_.c_txtInOut.text = "";
  50.       }
  51.    }
  52.    function clickedNext(_tempRef)
  53.    {
  54.       var _loc1_ = _tempRef;
  55.       _loc1_.c_txtInOut.setTextFormat(_loc1_.c_initTextFormat);
  56.       Selection.setFocus();
  57.       _loc1_.c_txtInOut.type = "Dynamic";
  58.       _loc1_.c_txtInOut.selectable = false;
  59.       _loc1_.c_txtInOut.border = false;
  60.    }
  61.    function funKeypressed(_tempRef)
  62.    {
  63.       var _loc1_ = this;
  64.       if(_tempRef.c_txtInOut.text == "" || _loc1_.c_txtInOut == null || _loc1_.c_txtInOut == undefined)
  65.       {
  66.          _loc1_.c_mcNext._visible = false;
  67.       }
  68.       else
  69.       {
  70.          _loc1_.c_mcNext._visible = true;
  71.       }
  72.    }
  73.    function textFormat()
  74.    {
  75.       var _loc1_ = this;
  76.       _loc1_.c_initTextFormat = new TextFormat();
  77.       _loc1_.c_initTextFormat.font = "Tahoma";
  78.       _loc1_.c_initTextFormat.size = 12;
  79.       _loc1_.c_initTextFormat.color = 102;
  80.       _loc1_.c_initTextFormat.align = "center";
  81.       _loc1_.c_initTextFormat.bold = true;
  82.       _loc1_.c_clickedTextFormat = new TextFormat();
  83.       _loc1_.c_clickedTextFormat.font = "Tahoma";
  84.       _loc1_.c_clickedTextFormat.size = 12;
  85.       _loc1_.c_clickedTextFormat.color = 0;
  86.       _loc1_.c_clickedTextFormat.align = "left";
  87.       _loc1_.c_clickedTextFormat.bold = false;
  88.    }
  89.    function setEvents()
  90.    {
  91.       var _loc1_ = this;
  92.       _loc1_.c_mcSourceClip.objRef = _loc1_;
  93.       var tempRef = _loc1_;
  94.       _loc1_.c_mcSourceClip.onRollOver = function()
  95.       {
  96.          this.objRef.c_mcRolloverClip.gotoAndStop("white");
  97.       };
  98.       _loc1_.c_mcSourceClip.onRollOut = function()
  99.       {
  100.          this.objRef.c_mcRolloverClip.gotoAndStop("blue");
  101.       };
  102.       _loc1_.c_mcSourceClip.onRelease = function()
  103.       {
  104.          this.gotoAndStop("inp");
  105.          Key.addListener(Key_listener);
  106.          this.objRef.clickedText();
  107.       };
  108.       _loc1_.c_mcNext.onRelease = function()
  109.       {
  110.          tempRef.c_mcSourceClip.gotoAndStop("dyn");
  111.          tempRef.c_blnNextClicked = true;
  112.          tempRef.clickedNext(tempRef);
  113.          Key.removeListener(Key_listener);
  114.          tempRef.checkAns(tempRef);
  115.       };
  116.       var Key_listener = new Object();
  117.       Key_listener.onKeyUp = function()
  118.       {
  119.          tempRef.funKeypressed(tempRef);
  120.       };
  121.    }
  122.    function checkAns(_tempRef)
  123.    {
  124.       var _loc2_ = _tempRef;
  125.       _loc2_.c_arrCorrAns = _loc2_.c_strCorrAns.split(",");
  126.       var arrLength = _loc2_.c_arrCorrAns.length;
  127.       var _loc3_ = false;
  128.       var _loc1_ = 0;
  129.       while(_loc1_ < arrLength)
  130.       {
  131.          trace(_loc2_.c_arrCorrAns[_loc1_]);
  132.          if(_loc2_.c_txtInOut.text == _loc2_.c_arrCorrAns[_loc1_])
  133.          {
  134.             _loc3_ = true;
  135.             break;
  136.          }
  137.          _loc3_ = false;
  138.          _loc1_ = _loc1_ + 1;
  139.       }
  140.       if(_loc3_)
  141.       {
  142.          trace("correct ans");
  143.       }
  144.       else
  145.       {
  146.          trace("wrong ans");
  147.       }
  148.    }
  149. }
  150.