home *** CD-ROM | disk | FTP | other *** search
/ Equipe de France et Bonbons / EquipeFrancePromoCD.iso / pages / cs_cadbury / loadergfx.swf / scripts / __Packages / DialogGeneratorHandler.as < prev    next >
Encoding:
Text File  |  2006-03-19  |  4.3 KB  |  157 lines

  1. class DialogGeneratorHandler
  2. {
  3.    var mc;
  4.    var mcProfTotal;
  5.    var msgFailureArray;
  6.    var tipsNumber;
  7.    var tipsMode;
  8.    var tipsTimer;
  9.    var noTipsTimer;
  10.    var tipsDelay;
  11.    var noTipsDelay;
  12.    var msgTips;
  13.    var msgTodo;
  14.    var msgSuccess;
  15.    function DialogGeneratorHandler(mc, mcProfTotal)
  16.    {
  17.       this.mc = mc;
  18.       this.mcProfTotal = mcProfTotal;
  19.       this.msgFailureArray = new Array();
  20.       this.tipsNumber = 0;
  21.       this.tipsMode = "tips";
  22.       this.tipsTimer = new TimerSynchronizer();
  23.       this.noTipsTimer = new TimerSynchronizer();
  24.       this.tipsDelay = 3000;
  25.       this.noTipsDelay = 3000;
  26.    }
  27.    function setMsgTips(msgTips)
  28.    {
  29.       this.msgTips = msgTips;
  30.    }
  31.    function setMsgTodo(msgTodo)
  32.    {
  33.       this.msgTodo = msgTodo;
  34.    }
  35.    function setMsgSuccess(msgSuccess)
  36.    {
  37.       this.msgSuccess = msgSuccess;
  38.    }
  39.    function setMsgFailureType0(msgFailureType0)
  40.    {
  41.       this.msgFailureArray[0] = msgFailureType0;
  42.    }
  43.    function setMsgFailureType1(msgFailureType1)
  44.    {
  45.       this.msgFailureArray[1] = msgFailureType1;
  46.    }
  47.    function setMsgFailureType2(msgFailureType2)
  48.    {
  49.       this.msgFailureArray[2] = msgFailureType2;
  50.    }
  51.    function playTips()
  52.    {
  53.       this.mcProfTotal.mcProfBubble._visible = true;
  54.       this.mc.F3 = "";
  55.       this.mc.F4 = "";
  56.       this.mc.F5 = "";
  57.       this.mc.F6 = "";
  58.       if(this.msgTips == undefined || this.msgTodo == undefined)
  59.       {
  60.          trace("DialogGeneratorHandler - msgTips and/or msgTodo are undefined !");
  61.          this.mc.F1 = "";
  62.          this.mc.F2 = "";
  63.          return undefined;
  64.       }
  65.       if(this.tipsNumber > this.msgTips.length || this.tipsNumber > this.msgTodo.length)
  66.       {
  67.          trace("DialogGeneratorHandler - Bad Tips number !");
  68.          this.mc.F1 = "";
  69.          this.mc.F2 = "";
  70.          return undefined;
  71.       }
  72.       this.mc.F1 = this.msgTips[this.tipsNumber];
  73.       this.mc.F2 = this.msgTodo[this.tipsNumber];
  74.       this.tipsMode = "tips";
  75.       this.tipsTimer.setOldTimer(getTimer());
  76.    }
  77.    function playMsgSuccess(customMsg)
  78.    {
  79.       this.mcProfTotal.mcProfBubble._visible = true;
  80.       this.mc.F1 = "";
  81.       this.mc.F2 = "";
  82.       this.mc.F4 = customMsg;
  83.       this.mc.F5 = "";
  84.       this.mc.F6 = "";
  85.       if(this.msgSuccess == undefined)
  86.       {
  87.          trace("DialogGeneratorHandler - msgSuccess is undefined !");
  88.          this.mc.F3 = "";
  89.          return undefined;
  90.       }
  91.       var _loc2_ = random(this.msgSuccess.length);
  92.       this.mc.F3 = this.msgSuccess[_loc2_];
  93.       this.tipsMode = "noTips";
  94.       this.noTipsTimer.setOldTimer(getTimer());
  95.    }
  96.    function playMsgFailure(errorType, customMsg)
  97.    {
  98.       this.mcProfTotal.mcProfBubble._visible = true;
  99.       this.mc.F1 = "";
  100.       this.mc.F2 = "";
  101.       this.mc.F3 = "";
  102.       this.mc.F4 = customMsg;
  103.       this.mc.F6 = "";
  104.       if(this.msgFailureArray[errorType] == undefined)
  105.       {
  106.          trace("DialogGeneratorHandler - msgFailureArray " + errorType + "s is undefined !");
  107.          this.mc.F5 = "";
  108.          return undefined;
  109.       }
  110.       var _loc2_ = this.msgFailureArray[errorType];
  111.       var _loc4_ = random(_loc2_.length);
  112.       this.mc.F5 = _loc2_[_loc4_];
  113.       this.tipsMode = "noTips";
  114.       this.noTipsTimer.setOldTimer(getTimer());
  115.    }
  116.    function playMsgCustom(msgCustom)
  117.    {
  118.       this.mcProfTotal.mcProfBubble._visible = true;
  119.       this.mc.F1 = "";
  120.       this.mc.F2 = "";
  121.       this.mc.F3 = "";
  122.       this.mc.F4 = "";
  123.       this.mc.F5 = "";
  124.       this.mc.F6 = msgCustom;
  125.       this.tipsMode = "noTips";
  126.       this.noTipsTimer.setOldTimer(getTimer());
  127.    }
  128.    function playNothing()
  129.    {
  130.       this.mcProfTotal.mcProfBubble._visible = false;
  131.       this.mc.F1 = "";
  132.       this.mc.F2 = "";
  133.       this.mc.F3 = "";
  134.       this.mc.F4 = "";
  135.       this.mc.F5 = "";
  136.       this.mc.F6 = "";
  137.       this.tipsMode = "nothing";
  138.    }
  139.    function setTipsNumber(n)
  140.    {
  141.       this.tipsNumber = n;
  142.    }
  143.    function manageDisplay()
  144.    {
  145.       if(this.tipsMode == "tips" && this.tipsTimer.getElapsedTimeMs() > this.tipsDelay)
  146.       {
  147.          this.playNothing();
  148.          this.tipsMode == "nothing";
  149.       }
  150.       if(this.tipsMode == "noTips" && this.noTipsTimer.getElapsedTimeMs() > this.noTipsDelay)
  151.       {
  152.          this.playTips();
  153.          this.tipsMode = "tips";
  154.       }
  155.    }
  156. }
  157.