home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 145 / MOBICLIC145.ISO / pc / DATA / DSS145 / DSS145_12 / DSS145_12.swf / scripts / dss145_12 / AttenteJeu.as < prev    next >
Text File  |  2012-07-19  |  26KB  |  722 lines

  1. package dss145_12
  2. {
  3.    import com.milanpresse.engineaddons.facades.EngineExt;
  4.    import com.milanpresse.engineaddons.initdisplayobject.ExtendedClip;
  5.    import com.milanpresse.engineaddons.labelstypes.AttenteLabel;
  6.    import com.milanpresse.tools.*;
  7.    import flash.display.MovieClip;
  8.    import flash.events.Event;
  9.    import flash.events.KeyboardEvent;
  10.    import flash.events.TimerEvent;
  11.    import flash.geom.Point;
  12.    import flash.utils.Timer;
  13.    import flash.utils.getTimer;
  14.    
  15.    public class AttenteJeu extends AttenteLabel
  16.    {
  17.        
  18.       
  19.       public var CONTAINER:MovieClip;
  20.       
  21.       public var mainAlgo:CapsuleAlgo;
  22.       
  23.       public var BT_REJOUER:ExtendedClip;
  24.       
  25.       public var BT_AIDE:ExtendedClip;
  26.       
  27.       public var DECOR:Decor;
  28.       
  29.       public var PERSO:Perso;
  30.       
  31.       public var CLIP_AIDE:ExtendedClip;
  32.       
  33.       public var enemies:Vector.<Enemy>;
  34.       
  35.       public var QUIZZ_FEN:MovieClip;
  36.       
  37.       public var CHRONO:MovieClip;
  38.       
  39.       private var _timer:Timer;
  40.       
  41.       private var _timerFallEnd:Timer;
  42.       
  43.       private var _questionsJeuManager:Questions;
  44.       
  45.       private var _questionOriginalList:Vector.<Question>;
  46.       
  47.       private var _timerToStop:Array;
  48.       
  49.       private var _timerToStart:Array;
  50.       
  51.       private var actions:Object;
  52.       
  53.       private var keyToAction:Object;
  54.       
  55.       private var posGlobal:Point;
  56.       
  57.       private var containerPosOriginal:Point;
  58.       
  59.       private var _enemiesManager:EnemiesAttackManager;
  60.       
  61.       private var _startTime:int;
  62.       
  63.       private var _ennemyCollided:Enemy;
  64.       
  65.       private var _oiseauIntervalTime:int = 20000;
  66.       
  67.       private var _oiseauLastTime:int = 0;
  68.       
  69.       private var _oiseau:MovieClip;
  70.       
  71.       private var _oiseauIsFlying:Boolean = false;
  72.       
  73.       private var lastState:String = "";
  74.       
  75.       private var _b_chute_AlreadyPlay:Boolean = false;
  76.       
  77.       private var bonusNb:int = 5;
  78.       
  79.       private var causeOfFail:String = null;
  80.       
  81.       private var causeToBadComments:Object;
  82.       
  83.       private var _quizReponsesClip:Vector.<ExtendedClip>;
  84.       
  85.       private var _quizFenIsInitialised:Boolean = false;
  86.       
  87.       private var _timerToWake:Boolean = false;
  88.       
  89.       private var _timerFallEndToWake:Boolean = false;
  90.       
  91.       public function AttenteJeu(param1:EngineExt, param2:MovieClip, param3:Function = null)
  92.       {
  93.          this.enemies = new Vector.<Enemy>();
  94.          this._timerFallEnd = new Timer(3000,1);
  95.          this._questionOriginalList = new Vector.<Question>();
  96.          this._timerToStop = [];
  97.          this._timerToStart = [];
  98.          this.actions = {
  99.             "left":false,
  100.             "up":false,
  101.             "right":false,
  102.             "down":false
  103.          };
  104.          this.keyToAction = {
  105.             37:"left",
  106.             38:"up",
  107.             39:"right",
  108.             40:"down"
  109.          };
  110.          this.causeToBadComments = {
  111.             "RAVIN":"BAD_01",
  112.             "FEU":"BAD_02",
  113.             "LAVE":"BAD_03",
  114.             "OISEAU":"BAD_04"
  115.          };
  116.          this._quizReponsesClip = new Vector.<ExtendedClip>();
  117.          super(param1,param3);
  118.          this.CONTAINER = param2;
  119.       }
  120.       
  121.       public function init() : void
  122.       {
  123.          var params1:XMLList = null;
  124.          var pt:Point = null;
  125.          this.DECOR = new Decor(this.CONTAINER);
  126.          this.PERSO = new Perso(this.DECOR,this.CONTAINER.HERAKLES);
  127.          params1 = _e.config.XmlConfig.Module.Config.Params.Param.(hasOwnProperty("@nom") && @nom == "invincible");
  128.          if(params1.length() > 0)
  129.          {
  130.             this.PERSO.invincible = params1[0].@valeur.toString() == "true" ? true : false;
  131.          }
  132.          this.BT_REJOUER = new ExtendedClip(this.CONTAINER.parent.getChildByName("BT_REJOUER") as MovieClip,_e);
  133.          this.BT_REJOUER.onPressState = {"label":"E1"};
  134.          this.BT_REJOUER.onRollOverState = {
  135.             "label":"E2",
  136.             "noiseCode":"B_REJ"
  137.          };
  138.          this.BT_REJOUER.onRollOutState = {"label":"E1"};
  139.          this.BT_REJOUER.onPress = function():void
  140.          {
  141.             this.visible = false;
  142.             this.enabled = false;
  143.             gameRestart2();
  144.          };
  145.          this.BT_REJOUER.onRollOut = function():void
  146.          {
  147.             _e.noiseStop({"code":"B_REJ"});
  148.          };
  149.          this.BT_REJOUER.visible = false;
  150.          this.BT_REJOUER.enabled = false;
  151.          this.BT_REJOUER.init();
  152.          this.CLIP_AIDE = new ExtendedClip(this.CONTAINER.parent.getChildByName("AIDE") as MovieClip,_e);
  153.          this.CLIP_AIDE.onPressState = {};
  154.          this.CLIP_AIDE.onRollOverState = {};
  155.          this.CLIP_AIDE.onRollOutState = {};
  156.          this.CLIP_AIDE.onPress = function():void
  157.          {
  158.             this.visible = false;
  159.             this.enabled = false;
  160.             CLIP_AIDE.gotoAndStop(1);
  161.             gameResume();
  162.          };
  163.          this.CLIP_AIDE.visible = false;
  164.          this.CLIP_AIDE.enabled = false;
  165.          this.CLIP_AIDE.init();
  166.          this.BT_AIDE = new ExtendedClip(this.CONTAINER.parent.getChildByName("BT_AIDE") as MovieClip,_e);
  167.          this.BT_AIDE.onPressState = {"label":"E1"};
  168.          this.BT_AIDE.onRollOverState = {
  169.             "label":"E2",
  170.             "noiseCode":"B_AIDE"
  171.          };
  172.          this.BT_AIDE.onRollOutState = {"label":"E1"};
  173.          this.BT_AIDE.onPress = function():void
  174.          {
  175.             gamePause();
  176.             CLIP_AIDE.gotoAndPlay(2);
  177.             CLIP_AIDE.visible = true;
  178.             CLIP_AIDE.enabled = true;
  179.          };
  180.          this.BT_AIDE.visible = true;
  181.          this.BT_AIDE.enabled = true;
  182.          this.BT_AIDE.init();
  183.          this._enemiesManager = new EnemiesAttackManager(this.DECOR,this.PERSO);
  184.          this.QUIZZ_FEN = (this.CONTAINER.parent as MovieClip).QUIZZ_FEN;
  185.          this.CONTAINER.parent.removeChild(this.QUIZZ_FEN);
  186.          this.createQuestionsListe();
  187.          this._questionsJeuManager.next();
  188.          this._oiseau = this.CONTAINER.OISEAU;
  189.          this._oiseau.gotoAndStop(1);
  190.          this.CONTAINER.removeChild(this._oiseau);
  191.          this.CHRONO = _e.timelineLinearSet((this.CONTAINER.parent as MovieClip).CHRONO,this);
  192.          this.CHRONO.timeline.GotoAndStop(1);
  193.          this.containerPosOriginal = new Point(this.CONTAINER.x,this.CONTAINER.y);
  194.          this._timer = new Timer(1);
  195.          this._timer.addEventListener(TimerEvent.TIMER,this.gameLoop);
  196.          this.CONTAINER.stage.addEventListener(KeyboardEvent.KEY_DOWN,this.keyDownHandler);
  197.          this.CONTAINER.stage.addEventListener(KeyboardEvent.KEY_UP,this.keyUpHandler);
  198.          pt = new Point(400,300);
  199.          pt = this.CONTAINER.globalToLocal(pt);
  200.          this._oiseau.x = pt.x;
  201.          this._oiseau.y = pt.y;
  202.          this.go();
  203.       }
  204.       
  205.       public function gamePause() : void
  206.       {
  207.          this._timerToStart = [];
  208.          if(this._timer.running)
  209.          {
  210.             this._timer.stop();
  211.             this._timerToStart.push(this._timer);
  212.          }
  213.          if(this._timerFallEnd.running)
  214.          {
  215.             this._timerFallEnd.stop();
  216.             this._timerToStart.push(this._timerFallEnd);
  217.          }
  218.          if(this._oiseau.isFlying)
  219.          {
  220.             this._oiseau.stop();
  221.          }
  222.          if(this.CHRONO.isRunning)
  223.          {
  224.             this.CHRONO.stop();
  225.          }
  226.       }
  227.       
  228.       public function gameResume() : void
  229.       {
  230.          var _loc1_:int = 0;
  231.          while(_loc1_ < this._timerToStart.length)
  232.          {
  233.             this._timerToStart[_loc1_].start();
  234.             _loc1_++;
  235.          }
  236.          if(this._oiseau.isFlying)
  237.          {
  238.             this._oiseau.play();
  239.          }
  240.          if(this.CHRONO.isRunning)
  241.          {
  242.             this.CHRONO.play();
  243.          }
  244.       }
  245.       
  246.       private function reset() : void
  247.       {
  248.          if(this.QUIZZ_FEN.parent != null)
  249.          {
  250.             this.QUIZZ_FEN.parent.removeChild(this.QUIZZ_FEN);
  251.          }
  252.          this.CONTAINER.stage.focus = this.CONTAINER.stage;
  253.          this._timer.reset();
  254.          this._enemiesManager.enemiesRemove();
  255.          this._oiseau.isFlying = false;
  256.          this._oiseau.gotoAndStop(1);
  257.          this._oiseau.OISEAU.gotoAndStop("E1");
  258.          this._enemiesManager.startTime = this._startTime = this._oiseauLastTime = getTimer();
  259.       }
  260.       
  261.       private function go() : void
  262.       {
  263.          this.redrawAll();
  264.          this.CHRONO.visible = true;
  265.          this.CHRONO.timeline.GotoAndPlayUntilTheEnd(1,this.run);
  266.          this.CHRONO.isRunning = true;
  267.       }
  268.       
  269.       private function gameContinue() : void
  270.       {
  271.          this.reset();
  272.          this.PERSO.resetContinue();
  273.          this._ennemyCollided = null;
  274.          this.go();
  275.       }
  276.       
  277.       private function gameRestart() : void
  278.       {
  279.          this.reset();
  280.          this.PERSO.reset();
  281.          this.bonusNb = 0;
  282.          this.bonusRefresh();
  283.          this._ennemyCollided = null;
  284.          this.redrawAll();
  285.          this.BT_REJOUER.enabled = true;
  286.          this.BT_REJOUER.visible = true;
  287.       }
  288.       
  289.       private function gameRestart2() : void
  290.       {
  291.          this.bonusNb = 5;
  292.          this.bonusRefresh();
  293.          this.go();
  294.       }
  295.       
  296.       private function createQuestionsListe() : void
  297.       {
  298.          var xmllist:XMLList = null;
  299.          var xmllist2:XMLList = null;
  300.          var question:Question = null;
  301.          var node:XML = null;
  302.          var node2:XML = null;
  303.          var reponse:Reponse = null;
  304.          var j:int = 0;
  305.          this._questionsJeuManager = new Questions();
  306.          var questions:Vector.<Question> = new Vector.<Question>();
  307.          var i:int = 1;
  308.          while(i <= 5)
  309.          {
  310.             xmllist = _e.config.XmlConfig.Module[_e.config.lang].LegendesMedias.*.(hasOwnProperty("@id") && @id.search("LM_Q_" + GlobalesFunctions.gimme2digits(i)) != -1);
  311.             if(xmllist.length() <= 0)
  312.             {
  313.                break;
  314.             }
  315.             node = xmllist[0];
  316.             question = new Question();
  317.             question.no = i;
  318.             question.idLM = node.@id;
  319.             question.text = node.toString();
  320.             j = 1;
  321.             while(j <= 3)
  322.             {
  323.                node2 = _e.config.XmlConfig.Module[_e.config.lang].LegendesMedias.*.(hasOwnProperty("@id") && @id.search("LM_R_" + GlobalesFunctions.gimme2digits(i) + "_" + GlobalesFunctions.gimme2digits(j)) != -1)[0];
  324.                reponse = new Reponse();
  325.                reponse.good = j == 1 ? true : false;
  326.                reponse.no = j;
  327.                reponse.idLM = node2.@id.toString();
  328.                reponse.text = node2.toString();
  329.                question.reponses.push(reponse);
  330.                j++;
  331.             }
  332.             this._questionsJeuManager.addQuestion(question);
  333.             i++;
  334.          }
  335.          this._questionOriginalList = this._questionsJeuManager.questions.slice();
  336.       }
  337.       
  338.       private function run() : void
  339.       {
  340.          _e.noisePlay({"code":"B_CHRONO"});
  341.          this.CHRONO.visible = false;
  342.          this.CHRONO.isRunning = false;
  343.          this._enemiesManager.startTime = this._startTime = this._oiseauLastTime = getTimer();
  344.          this._timer.start();
  345.       }
  346.       
  347.       private function keyDownHandler(param1:KeyboardEvent) : void
  348.       {
  349.          this.actions[this.keyToAction[param1.keyCode]] = true;
  350.       }
  351.       
  352.       private function keyUpHandler(param1:KeyboardEvent) : void
  353.       {
  354.          this.actions[this.keyToAction[param1.keyCode]] = false;
  355.       }
  356.       
  357.       private function oiseauHandler(param1:Event) : void
  358.       {
  359.          if(this._oiseau.currentFrame >= this._oiseau.totalFrames)
  360.          {
  361.             this.CONTAINER.stage.removeEventListener(Event.ENTER_FRAME,this.oiseauHandler);
  362.             this.CONTAINER.removeChild(this._oiseau);
  363.             this._oiseau.isFlying = false;
  364.          }
  365.       }
  366.       
  367.       private function gameLoop(param1:TimerEvent) : void
  368.       {
  369.          var _loc3_:Number = NaN;
  370.          if(this._ennemyCollided != null)
  371.          {
  372.             return;
  373.          }
  374.          this.PERSO.move(this.actions);
  375.          if(this.PERSO.isArrivedToEnd)
  376.          {
  377.             this.stopAll();
  378.             this.gameSucces();
  379.             return;
  380.          }
  381.          if(getTimer() - this._oiseauLastTime >= this._oiseauIntervalTime)
  382.          {
  383.             this._oiseauIsFlying = true;
  384.             this._oiseauLastTime = getTimer();
  385.             this.CONTAINER.addChild(this._oiseau);
  386.             this._oiseau.gotoAndPlay(1);
  387.             this._oiseau.isFlying = true;
  388.             this._oiseau.visible = true;
  389.             this._oiseau.x = 400;
  390.             this._oiseau.y = this.PERSO.y;
  391.             this.CONTAINER.stage.addEventListener(Event.ENTER_FRAME,this.oiseauHandler);
  392.          }
  393.          var _loc2_:Point = this._oiseau.localToGlobal(new Point(this._oiseau.OISEAU.x,this._oiseau.OISEAU.y - 95));
  394.          _loc2_ = this.CONTAINER.globalToLocal(_loc2_);
  395.          if(this.PERSO.invincible == false)
  396.          {
  397.             _loc3_ = Point.distance(new Point(this.PERSO.x,this.PERSO.y),_loc2_);
  398.             if(_loc3_ < 30)
  399.             {
  400.                this._timer.stop();
  401.                this.CONTAINER.stage.removeEventListener(Event.ENTER_FRAME,this.oiseauHandler);
  402.                this.PERSO.isJumping = false;
  403.                this.CONTAINER.stage.removeEventListener(Event.ENTER_FRAME,this.jumpHandler);
  404.                this.CONTAINER.HERAKLES.STATE.gotoAndStop("E4");
  405.                this.causeOfFail = "OISEAU";
  406.                this._oiseau.stop();
  407.                this._oiseau.OISEAU.gotoAndStop("E2");
  408.                _e.noisePlay({"code":"B_PIAF"});
  409.                this._timerFallEnd.addEventListener(TimerEvent.TIMER_COMPLETE,this.endFallHandler);
  410.                this._timerFallEnd.start();
  411.                return;
  412.             }
  413.             this._enemiesManager.update(getTimer());
  414.             this._ennemyCollided = this._enemiesManager.detectCollision(this.PERSO);
  415.             if(this._ennemyCollided != null)
  416.             {
  417.                this.stopAll();
  418.                this.causeOfFail = this._ennemyCollided.type;
  419.                this.PERSO.isJumping = false;
  420.                this.CONTAINER.stage.removeEventListener(Event.ENTER_FRAME,this.jumpHandler);
  421.                if(this._ennemyCollided.type == "FEU")
  422.                {
  423.                   this._enemiesManager.enemyRemove(this._ennemyCollided);
  424.                   _e.noisePlay({"code":"B_FEU"});
  425.                   this.CONTAINER.HERAKLES.STATE.gotoAndStop("E2");
  426.                   this._timerFallEnd.addEventListener(TimerEvent.TIMER_COMPLETE,this.endFallHandler);
  427.                   this._timerFallEnd.start();
  428.                }
  429.                else if(this._ennemyCollided.type == "LAVE")
  430.                {
  431.                   this._enemiesManager.enemyRemove(this._ennemyCollided);
  432.                   _e.noisePlay({"code":"B_LAVE"});
  433.                   this.CONTAINER.HERAKLES.STATE.gotoAndStop("E3");
  434.                   this._timerFallEnd.addEventListener(TimerEvent.TIMER_COMPLETE,this.endFallHandler);
  435.                   this._timerFallEnd.start();
  436.                }
  437.                return;
  438.             }
  439.          }
  440.          this.redrawAll();
  441.       }
  442.       
  443.       private function redrawAll() : void
  444.       {
  445.          this.posGlobal = this.CONTAINER.parent.localToGlobal(new Point(this.PERSO.x,this.PERSO.y));
  446.          var _loc1_:Number = 300 - this.posGlobal.y;
  447.          if(_loc1_ - this.containerPosOriginal.y > 0 && _loc1_ - this.containerPosOriginal.y < 1168)
  448.          {
  449.             this.CONTAINER.y = _loc1_;
  450.          }
  451.          else if(_loc1_ - this.containerPosOriginal.y <= 0)
  452.          {
  453.             this.CONTAINER.y = this.containerPosOriginal.y;
  454.          }
  455.          else if(_loc1_ - this.containerPosOriginal.y >= 1168)
  456.          {
  457.             this.CONTAINER.y = -345;
  458.          }
  459.          this.CONTAINER.HERAKLES.x = this.PERSO.x;
  460.          this.CONTAINER.HERAKLES.y = this.PERSO.y;
  461.          if(this.PERSO.state == Perso.UPSTAIRS_STOP)
  462.          {
  463.             this.PERSO.isJumping = false;
  464.             this.CONTAINER.stage.removeEventListener(Event.ENTER_FRAME,this.jumpHandler);
  465.             if(this.CONTAINER.HERAKLES.currentFrameLabel != Perso.GO_UP)
  466.             {
  467.                this.CONTAINER.HERAKLES.gotoAndStop(Perso.GO_UP);
  468.             }
  469.             this.CONTAINER.HERAKLES.STATE.STATE2.stop();
  470.          }
  471.          else if(this.PERSO.state == Perso.JUMP_LEFT || this.PERSO.state == Perso.JUMP_RIGHT)
  472.          {
  473.             if(this.CONTAINER.HERAKLES.currentFrameLabel != this.PERSO.state || this.PERSO.isJumping == false)
  474.             {
  475.                this.PERSO.isJumping = true;
  476.                this.CONTAINER.HERAKLES.gotoAndStop(this.PERSO.state);
  477.                this.CONTAINER.HERAKLES.STATE.STATE2.gotoAndPlay(1);
  478.                this.CONTAINER.stage.addEventListener(Event.ENTER_FRAME,this.jumpHandler);
  479.             }
  480.          }
  481.          else if(this.PERSO.state == Perso.FALL_END_LEFT || this.PERSO.state == Perso.FALL_END_RIGHT)
  482.          {
  483.             this.stopAll();
  484.             this._b_chute_AlreadyPlay = false;
  485.             _e.noiseStop({"code":"B_CHUTE"});
  486.             _e.noisePlay({"code":"B_BOUM"});
  487.             this.CONTAINER.HERAKLES.STATE.gotoAndStop("E2");
  488.             this.causeOfFail = "RAVIN";
  489.             this._timerFallEnd.addEventListener(TimerEvent.TIMER_COMPLETE,this.endFallHandler);
  490.             this._timerFallEnd.start();
  491.          }
  492.          else
  493.          {
  494.             if(this.PERSO.isFalling)
  495.             {
  496.                if(this._b_chute_AlreadyPlay == false)
  497.                {
  498.                   this._b_chute_AlreadyPlay = true;
  499.                   _e.noisePlay({"code":"B_CHUTE"});
  500.                }
  501.             }
  502.             this.PERSO.isJumping = false;
  503.             this.CONTAINER.stage.removeEventListener(Event.ENTER_FRAME,this.jumpHandler);
  504.             if(this.CONTAINER.HERAKLES.currentFrameLabel != this.PERSO.state)
  505.             {
  506.                this.CONTAINER.HERAKLES.gotoAndStop(this.PERSO.state);
  507.             }
  508.             if(this.PERSO.state == Perso.GO_UP || this.PERSO.state == Perso.GO_DOWN)
  509.             {
  510.                this.CONTAINER.HERAKLES.STATE.STATE2.play();
  511.             }
  512.             if(this.PERSO.state == Perso.DUCK_LEFT || this.PERSO.state == Perso.DUCK_RIGHT)
  513.             {
  514.                this.CONTAINER.HERAKLES.STATE.STATE2.gotoAndStop("FIN");
  515.             }
  516.          }
  517.          _e.timelineManager.addMovie(this.CONTAINER.HERAKLES);
  518.          _e.timelineManager.addMovie(this.CONTAINER.HERAKLES.STATE);
  519.          this.lastState = this.PERSO.state;
  520.       }
  521.       
  522.       private function stopAll() : void
  523.       {
  524.          this._timer.stop();
  525.          this._oiseau.gotoAndStop(1);
  526.          if(this._oiseau.parent != null)
  527.          {
  528.             this.CONTAINER.removeChild(this._oiseau);
  529.          }
  530.          this.CONTAINER.stage.removeEventListener(Event.ENTER_FRAME,this.oiseauHandler);
  531.       }
  532.       
  533.       public function bonusRefresh() : void
  534.       {
  535.          var _loc1_:MovieClip = null;
  536.          var _loc2_:int = 1;
  537.          while(_loc2_ <= 5)
  538.          {
  539.             _loc1_ = this.CONTAINER.parent.getChildByName("BONUS_0" + _loc2_) as MovieClip;
  540.             if(_loc2_ <= this.bonusNb)
  541.             {
  542.                _loc1_.gotoAndPlay(1);
  543.                _loc1_.visible = true;
  544.             }
  545.             else
  546.             {
  547.                _loc1_.gotoAndStop(1);
  548.                _loc1_.visible = false;
  549.             }
  550.             _loc2_++;
  551.          }
  552.       }
  553.       
  554.       private function endFallHandler(param1:TimerEvent) : void
  555.       {
  556.          var event:TimerEvent = param1;
  557.          this._timerFallEnd.removeEventListener(TimerEvent.TIMER_COMPLETE,this.endFallHandler);
  558.          this._timerFallEnd.reset();
  559.          if(this.bonusNb <= 0)
  560.          {
  561.             this.gameFailure();
  562.          }
  563.          else
  564.          {
  565.             --this.bonusNb;
  566.             this.bonusRefresh();
  567.             _e.noisePlay({
  568.                "code":"B_BONUS",
  569.                "callback":function():void
  570.                {
  571.                   _e.commentPlay({
  572.                      "code":causeToBadComments[causeOfFail],
  573.                      "callback":quizLaunch
  574.                   });
  575.                }
  576.             });
  577.          }
  578.       }
  579.       
  580.       private function gameFailure() : void
  581.       {
  582.          _e.commentPlay({
  583.             "code":"REJ",
  584.             "callback":this.gameRestart
  585.          });
  586.       }
  587.       
  588.       private function gameSucces() : void
  589.       {
  590.          this.gameEnd();
  591.       }
  592.       
  593.       private function gameEnd() : void
  594.       {
  595.          this.destroy();
  596.          _e.instanceToDestroyRemove(this);
  597.          _callbackEnd();
  598.       }
  599.       
  600.       private function quizLaunch() : void
  601.       {
  602.          var quizReponse:ExtendedClip = null;
  603.          var i:int = 0;
  604.          var j:int = 0;
  605.          this._questionsJeuManager.next();
  606.          this._questionsJeuManager.question.melangerReponses();
  607.          this._questionsJeuManager.question.melangerReponses();
  608.          this._questionsJeuManager.question.melangerReponses();
  609.          if(this._quizFenIsInitialised == false)
  610.          {
  611.             this._quizFenIsInitialised = true;
  612.             this.QUIZZ_FEN.QUESTION.textBloc = _e.textShow({
  613.                "id":this._questionsJeuManager.question.idLM,
  614.                "model":this.QUIZZ_FEN.QUESTION.TEXT,
  615.                "idStyle":"LM.LM_Q"
  616.             });
  617.             i = 1;
  618.             while(i <= 3)
  619.             {
  620.                this.QUIZZ_FEN["REP_0" + i].textBloc = _e.textShow({
  621.                   "id":this._questionsJeuManager.question.reponses[i - 1].idLM,
  622.                   "model":this.QUIZZ_FEN["REP_0" + i].TEXT,
  623.                   "idStyle":"LM.LM_Q"
  624.                });
  625.                quizReponse = new ExtendedClip(this.QUIZZ_FEN.getChildByName("REP_0" + i) as MovieClip,_e);
  626.                quizReponse.reponse = this._questionsJeuManager.question.reponses[i - 1];
  627.                quizReponse.onPressState = {"label":"E1"};
  628.                quizReponse.onRollOverState = {
  629.                   "label":"E2",
  630.                   "noiseCode":"B_REP"
  631.                };
  632.                quizReponse.onRollOutState = {"label":"E1"};
  633.                quizReponse.onPress = function():void
  634.                {
  635.                   if(this.reponse.good)
  636.                   {
  637.                      _e.commentPlay({
  638.                         "code":"Q_GOOD",
  639.                         "callback":gameContinue
  640.                      });
  641.                   }
  642.                   else
  643.                   {
  644.                      _e.commentPlay({
  645.                         "code":"Q_RATE",
  646.                         "callback":gameRestart
  647.                      });
  648.                   }
  649.                };
  650.                quizReponse.enabled = true;
  651.                quizReponse.init();
  652.                this._quizReponsesClip.push(quizReponse);
  653.                i++;
  654.             }
  655.          }
  656.          else
  657.          {
  658.             this.QUIZZ_FEN.QUESTION.textBloc.text = this._questionsJeuManager.question.text;
  659.             this.QUIZZ_FEN.QUESTION.textBloc.x = this.QUIZZ_FEN.QUESTION.TEXT.x + this.QUIZZ_FEN.QUESTION.TEXT.width / 2 - this.QUIZZ_FEN.QUESTION.textBloc.width / 2;
  660.             this.QUIZZ_FEN.QUESTION.textBloc.y = this.QUIZZ_FEN.QUESTION.TEXT.y + this.QUIZZ_FEN.QUESTION.TEXT.height / 2 - this.QUIZZ_FEN.QUESTION.textBloc.height / 2;
  661.             j = 1;
  662.             while(j <= this._quizReponsesClip.length)
  663.             {
  664.                this.QUIZZ_FEN["REP_0" + j].textBloc.text = this._questionsJeuManager.question.reponses[j - 1].text;
  665.                this.QUIZZ_FEN["REP_0" + j].textBloc.x = this.QUIZZ_FEN["REP_0" + j].TEXT.x + this.QUIZZ_FEN["REP_0" + j].TEXT.width / 2 - this.QUIZZ_FEN["REP_0" + j].textBloc.width / 2;
  666.                this.QUIZZ_FEN["REP_0" + j].textBloc.y = this.QUIZZ_FEN["REP_0" + j].TEXT.y + this.QUIZZ_FEN["REP_0" + j].TEXT.height / 2 - this.QUIZZ_FEN["REP_0" + j].textBloc.height / 2;
  667.                this._quizReponsesClip[j - 1].reponse = this._questionsJeuManager.question.reponses[j - 1];
  668.                j++;
  669.             }
  670.          }
  671.          this.CONTAINER.parent.addChild(this.QUIZZ_FEN);
  672.       }
  673.       
  674.       private function jumpHandler(param1:Event) : void
  675.       {
  676.          if(this.CONTAINER.HERAKLES.STATE.STATE2.currentFrame >= this.CONTAINER.HERAKLES.STATE.STATE2.totalFrames)
  677.          {
  678.             this.CONTAINER.stage.removeEventListener(Event.ENTER_FRAME,this.jumpHandler);
  679.             this.CONTAINER.HERAKLES.STATE.STATE2.stop();
  680.             this.PERSO.isJumping = false;
  681.          }
  682.       }
  683.       
  684.       public function sleep() : void
  685.       {
  686.          if(this._timer.running)
  687.          {
  688.             this._timerToWake = true;
  689.             this._timer.stop();
  690.          }
  691.          if(this._timerFallEnd.running)
  692.          {
  693.             this._timerFallEndToWake = true;
  694.             this._timerFallEnd.stop();
  695.          }
  696.       }
  697.       
  698.       public function wake() : void
  699.       {
  700.          if(this._timerToWake)
  701.          {
  702.             this._timerToWake = false;
  703.             this._timer.start();
  704.          }
  705.          if(this._timerFallEndToWake)
  706.          {
  707.             this._timerFallEndToWake = false;
  708.             this._timerFallEnd.start();
  709.          }
  710.       }
  711.       
  712.       public function destroy() : void
  713.       {
  714.          this._timerFallEnd.addEventListener(TimerEvent.TIMER_COMPLETE,this.endFallHandler);
  715.          this.CONTAINER.stage.addEventListener(Event.ENTER_FRAME,this.oiseauHandler);
  716.          this.CONTAINER.stage.removeEventListener(Event.ENTER_FRAME,this.jumpHandler);
  717.          this.CONTAINER.stage.removeEventListener(KeyboardEvent.KEY_DOWN,this.keyDownHandler);
  718.          this.CONTAINER.stage.removeEventListener(KeyboardEvent.KEY_UP,this.keyUpHandler);
  719.       }
  720.    }
  721. }
  722.