home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 159 / MOBICLIC159.ISO / mac / DATA / DSS159 / DSS159_01 / DSS159_01.swf / scripts / dss159_01 / ATTENTE.as < prev    next >
Text File  |  2013-11-19  |  40KB  |  1,044 lines

  1. package dss159_01
  2. {
  3.    import com.milanpresse.engine.events.GenericEvent;
  4.    import com.milanpresse.tools.GlobalesFunctions;
  5.    import dss159_01.engineaddons.facades.GameEngine;
  6.    import dss159_01.engineaddons.gamesprotos.Actor;
  7.    import dss159_01.engineaddons.gamesprotos.actors.actorClip.ActorClip;
  8.    import dss159_01.engineaddons.timers.TimerChild;
  9.    import dss159_01.engineaddons.visuals.SimpleBitmapData;
  10.    import flash.display.DisplayObjectContainer;
  11.    import flash.display.MovieClip;
  12.    import flash.display.Sprite;
  13.    import flash.geom.Point;
  14.    import flash.geom.Rectangle;
  15.    import flash.text.TextField;
  16.    import flash.utils.getDefinitionByName;
  17.    import flash.utils.getQualifiedClassName;
  18.    import flash.utils.getTimer;
  19.    
  20.    public class ATTENTE extends Actor
  21.    {
  22.        
  23.       
  24.       public var onEvent:Function = null;
  25.       
  26.       private var _container:ActorClip;
  27.       
  28.       private var mainLoop:TimerChild;
  29.       
  30.       private var LIMITES:ActorClip;
  31.       
  32.       private var level:int;
  33.       
  34.       private var levelConfig:Object;
  35.       
  36.       private var launcherManager:LauncherManager;
  37.       
  38.       private var OBJECTS_CONTAINER:ActorClip;
  39.       
  40.       private var plans:Actor;
  41.       
  42.       private var mapNum:int = 1;
  43.       
  44.       private var animSucces:ActorClip;
  45.       
  46.       private var controller;
  47.       
  48.       private var btRejouer:ActorClip;
  49.       
  50.       private var btRetour:ActorClip;
  51.       
  52.       private var elementsActor:Actor;
  53.       
  54.       private var SCORE:Score;
  55.       
  56.       private var demos:ActorClip;
  57.       
  58.       private var trailerLimitClip1:Sprite;
  59.       
  60.       private var _elements:Array;
  61.       
  62.       private var startTime:Number;
  63.       
  64.       private var lastTime:Number;
  65.       
  66.       private var delayTime:Number;
  67.       
  68.       private var elapsedTime:Number;
  69.       
  70.       private var noises:Array;
  71.       
  72.       private var ratio:Point;
  73.       
  74.       private var trailerClip:Sprite;
  75.       
  76.       private var trailerRunning:Boolean = false;
  77.       
  78.       private var endFlag:Object;
  79.       
  80.       private var perso:ActorClip;
  81.       
  82.       private var persoJumpHeight;
  83.       
  84.       var pt:Point;
  85.       
  86.       var pt2:Point;
  87.       
  88.       var marker1:Sprite;
  89.       
  90.       var marker2:Sprite;
  91.       
  92.       public function ATTENTE(param1:GameEngine, param2:ActorClip)
  93.       {
  94.          this.trailerLimitClip1 = new Sprite();
  95.          this._elements = [];
  96.          this.noises = [];
  97.          this.ratio = new Point();
  98.          this.trailerClip = new Sprite();
  99.          this.endFlag = {"globalX":1000000000000000000};
  100.          this.pt2 = new Point(0,0);
  101.          this.marker1 = new Sprite();
  102.          this.marker2 = new Sprite();
  103.          super(param1);
  104.          this._container = param2;
  105.          this.init();
  106.       }
  107.       
  108.       private function scoreInit() : void
  109.       {
  110.          var _loc1_:ActorClip = null;
  111.          this.SCORE = addActor(new Score(game,this._container.getChildByName("SCORE") as MovieClip));
  112.          this.SCORE["TXT_FLEURS"] = game.showTextBloc({
  113.             "text":"00",
  114.             "model":this.SCORE.clip.getChildByName("TXT_FLEURS") as TextField,
  115.             "idStyle":"LM.LM_SCORE01"
  116.          });
  117.          var _loc2_:int = 1;
  118.          while(_loc2_ <= 3)
  119.          {
  120.             _loc1_ = this.SCORE.addActor({"mc":this._container.getChildByName("SCORE.VIES.VIE_0" + _loc2_)});
  121.             _loc2_++;
  122.          }
  123.          this.SCORE["CLIP_TEMPS"] = addActor({"mc":this.SCORE.clip.getChildByName("TEMPS")});
  124.          this.SCORE["CLIP_TEMPS"].speed = -0.1;
  125.          this.SCORE["CLIP_TEMPS"].gotoAndStop(100);
  126.          this.SCORE.clip.parent.setChildIndex(this.SCORE.clip.clip,this.SCORE.clip.parent.numChildren - 1);
  127.          this.SCORE.setPoints("fleur",0);
  128.          this.SCORE.setPoints("vie",3);
  129.          this.SCORE.setPoints("temps",100);
  130.       }
  131.       
  132.       private function init() : void
  133.       {
  134.          this.level = game.memo.levelNo;
  135.          this.levelConfig = game.moduleConfig.levels[this.level - 1];
  136.          this.elementsActor = addActor();
  137.          this.noises["B_COURT"] = game.getNoise({"code":"B_COURT"});
  138.          this.animSucces = addActor({"mc":this._container.getChildByName("ANIM_SUCCES")});
  139.          this.btRejouer = addActor({
  140.             "mc":this._container.getChildByName("BT_REJOUER"),
  141.             "onRollOverState":{
  142.                "label":"E2",
  143.                "ibId":"IB_REJOUE"
  144.             },
  145.             "onRollOutState":{"label":"E1"},
  146.             "onClick":function(param1:ActorClip):void
  147.             {
  148.                btRejouer.visible = false;
  149.                animSucces.visible = false;
  150.                perso.gotoAndStop("E1");
  151.                perso.visible = true;
  152.                scoreReset();
  153.                startLevel(1);
  154.             },
  155.             "enabled":true,
  156.             "visible":false
  157.          });
  158.          this.trailerInit();
  159.          this.getElementsList();
  160.          this.persoInit();
  161.          this.scoreInit();
  162.          this.demosInit();
  163.          this._container.enabled = false;
  164.          this._container.clip.mouseChildren = true;
  165.          this.controller = new KeyController(stage);
  166.          this.mainLoop = game.mainTimer.addFromObj({
  167.             "delay":10,
  168.             "onDelay":this.loop
  169.          });
  170.          this.start();
  171.       }
  172.       
  173.       private function demosInit() : void
  174.       {
  175.          this.demos = addActor({"mc":this._container.getChildByName("DEMOS")});
  176.          this.demos.parent = null;
  177.       }
  178.       
  179.       private function trailerInit() : void
  180.       {
  181.          var _loc2_:SimpleBitmapData = null;
  182.          var _loc3_:DisplayObjectContainer = null;
  183.          this.plans = addActor();
  184.          var _loc1_:Number = 4;
  185.          _loc2_ = new SimpleBitmapData(game);
  186.          _loc2_.createFromMovieClip(this._container.getChildByName("DECOR.PLAN_CIEL"));
  187.          _loc2_.parent = this._container.clip;
  188.          this.plans["CIEL"] = this.plans.addActor(_loc2_);
  189.          this.plans["CIEL"].speed = -0.3 * _loc1_;
  190.          _loc2_ = new SimpleBitmapData(game);
  191.          _loc2_.createFromMovieClip(this._container.getChildByName("DECOR.PLAN_FORET"));
  192.          _loc2_.parent = this._container.clip;
  193.          this.plans["FORET"] = this.plans.addActor(_loc2_);
  194.          this.plans["FORET"].speed = -0.9 * _loc1_;
  195.          _loc2_ = new SimpleBitmapData(game);
  196.          _loc2_.createFromMovieClip(this._container.getChildByName("DECOR.PLAN_CHEMIN"));
  197.          _loc2_.parent = this._container.clip;
  198.          this.plans["CHEMIN"] = this.plans.addActor(_loc2_);
  199.          this.plans["CHEMIN"].speed = -1 * _loc1_;
  200.          this._container.clip.addChild(this.trailerClip);
  201.          this.trailerClip.x = 0;
  202.          this.trailerClip.addChild(this.trailerLimitClip1);
  203.          _loc3_ = this._container.getChildByName("DECOR.PLAN_CHEMIN2") as DisplayObjectContainer;
  204.          _loc3_.visible = false;
  205.          this._container.clip.removeChild(this._container.getChildByName("DECOR"));
  206.          this._container.clip.DECOR = null;
  207.          this.marker1.graphics.beginFill(65280,1);
  208.          this.marker1.graphics.drawCircle(0,0,10);
  209.          this.marker1.graphics.endFill();
  210.          this.marker1.visible = false;
  211.          this.marker2.graphics.beginFill(255,1);
  212.          this.marker2.graphics.drawRect(0,0,10,10);
  213.          this.marker2.graphics.endFill();
  214.          this.marker2.visible = false;
  215.       }
  216.       
  217.       public function getClass(param1:Object) : Class
  218.       {
  219.          return Class(getDefinitionByName(getQualifiedClassName(param1)));
  220.       }
  221.       
  222.       private function getElementsList() : void
  223.       {
  224.          var _loc1_:MovieClip = null;
  225.          var _loc2_:* = undefined;
  226.          var _loc3_:Class = null;
  227.          var _loc7_:TextField = null;
  228.          var _loc8_:Array = null;
  229.          game.mapNum = this.mapNum;
  230.          switch(this.mapNum)
  231.          {
  232.             case 1:
  233.                _loc1_ = new Level1() as MovieClip;
  234.                break;
  235.             case 2:
  236.                _loc1_ = new Level2() as MovieClip;
  237.                break;
  238.             case 3:
  239.                _loc1_ = new Level3() as MovieClip;
  240.          }
  241.          var _loc4_:int = _loc1_.numChildren;
  242.          var _loc5_:int = 0;
  243.          while(_loc5_ < _loc4_)
  244.          {
  245.             _loc2_ = _loc1_.getChildAt(_loc5_);
  246.             _loc3_ = this.getClass(_loc2_);
  247.             if(_loc3_ == MovieClip)
  248.             {
  249.                if(_loc2_.getChildByName("_infos") != null)
  250.                {
  251.                   _loc8_ = (_loc7_ = _loc2_.getChildByName("_infos") as TextField).text.split("\n");
  252.                }
  253.                else if(_loc2_.name.search(/^instance/) == -1)
  254.                {
  255.                   if(_loc2_.name.search(/^_helper/) == -1)
  256.                   {
  257.                      this._elements.push({
  258.                         "launched":false,
  259.                         "type":_loc2_.name,
  260.                         "clip":_loc2_,
  261.                         "time":0,
  262.                         "x":_loc2_.x,
  263.                         "y":_loc2_.y,
  264.                         "width":_loc2_.width,
  265.                         "height":_loc2_.height
  266.                      });
  267.                   }
  268.                }
  269.             }
  270.             else if(_loc3_ != Perso)
  271.             {
  272.                this._elements.push({
  273.                   "launched":false,
  274.                   "type":_loc3_,
  275.                   "clip":_loc2_,
  276.                   "time":0,
  277.                   "x":_loc2_.x,
  278.                   "y":_loc2_.y,
  279.                   "width":_loc2_.width,
  280.                   "height":_loc2_.height
  281.                });
  282.             }
  283.             _loc5_++;
  284.          }
  285.          this._elements = this._elements.sortOn("x",Array.NUMERIC);
  286.          var _loc6_:int = this._elements.length;
  287.          this.ratio.x = this.ratio.y = 600 / 218;
  288.          _loc5_ = 0;
  289.          while(_loc5_ < _loc6_)
  290.          {
  291.             this._elements[_loc5_].time = this._elements[_loc5_].x * 10;
  292.             if(this._elements[_loc5_].type == "FINISH")
  293.             {
  294.                this._elements[_loc5_].clip.scaleX *= this.ratio.x;
  295.                this._elements[_loc5_].clip.scaleY *= this.ratio.x;
  296.                this._elements[_loc5_].clip.x = this._elements[_loc5_].x * this.ratio.x;
  297.                this._elements[_loc5_].clip.y = this._elements[_loc5_].y * this.ratio.y;
  298.                this._elements[_loc5_].launched = false;
  299.                this._elements[_loc5_].passed = false;
  300.                this._elements[_loc5_].speed = this.plans["CHEMIN"].speed;
  301.                this._elements[_loc5_].clip.visible = false;
  302.                this._elements[_loc5_].infos = game.moduleConfig.elementsInfos["Finish"];
  303.                this.endFlag = this._elements[_loc5_];
  304.             }
  305.             else if(this._elements[_loc5_].type is Class)
  306.             {
  307.                if(game.moduleConfig.modeDisplay == "bitmap")
  308.                {
  309.                   this._elements[_loc5_].actor = this.elementsActor.addActor({
  310.                      "type":BitmapAnimClip,
  311.                      "clip":new this._elements[_loc5_].type()
  312.                   });
  313.                }
  314.                else
  315.                {
  316.                   this._elements[_loc5_].actor = this.elementsActor.addActor({
  317.                      "type":ActorClip,
  318.                      "mc":new this._elements[_loc5_].type()
  319.                   });
  320.                   this._elements[_loc5_].actor.gotoLabel = this._elements[_loc5_].actor.gotoAndStop;
  321.                }
  322.                this._elements[_loc5_].actor.scaleX = this._elements[_loc5_].clip.scaleX * this.ratio.x;
  323.                this._elements[_loc5_].actor.scaleY = this._elements[_loc5_].clip.scaleY * this.ratio.x;
  324.                this._elements[_loc5_].actor.x = this._elements[_loc5_].x * this.ratio.x;
  325.                this._elements[_loc5_].actor.y = this._elements[_loc5_].y * this.ratio.y;
  326.                this._elements[_loc5_].actor.gotoLabel("E1");
  327.                this._elements[_loc5_].speed = this.plans["CHEMIN"].speed;
  328.                this._elements[_loc5_].launched = false;
  329.                this._elements[_loc5_].passed = false;
  330.                this._elements[_loc5_].clip = this._elements[_loc5_].actor.clip;
  331.                this._elements[_loc5_].infos = game.moduleConfig.elementsInfos[getQualifiedClassName(this._elements[_loc5_].type)];
  332.             }
  333.             _loc5_++;
  334.          }
  335.       }
  336.       
  337.       private function objectsReset() : void
  338.       {
  339.          this.trailerClip.x = 0;
  340.          var _loc1_:int = 0;
  341.          while(_loc1_ < this._elements.length)
  342.          {
  343.             if(this._elements[_loc1_].infos.type == "finish")
  344.             {
  345.                this._elements[_loc1_].launched = false;
  346.                this._elements[_loc1_].passed = false;
  347.                this._elements[_loc1_].hitted = false;
  348.                this._elements[_loc1_].speed = this.plans["CHEMIN"].speed;
  349.                this._elements[_loc1_].clip.visible = false;
  350.                this.endFlag = this._elements[_loc1_];
  351.             }
  352.             else
  353.             {
  354.                this._elements[_loc1_].clip.x = this._elements[_loc1_].x * this.ratio.x;
  355.                this._elements[_loc1_].clip.y = this._elements[_loc1_].y * this.ratio.y;
  356.                this._elements[_loc1_].speed = this.plans["CHEMIN"].speed;
  357.                this._elements[_loc1_].hitted = false;
  358.                this._elements[_loc1_].launched = false;
  359.                this._elements[_loc1_].passed = false;
  360.                this._elements[_loc1_].actor.visible = true;
  361.                this._elements[_loc1_].actor.gotoLabel("E1");
  362.             }
  363.             _loc1_++;
  364.          }
  365.       }
  366.       
  367.       override public function start() : void
  368.       {
  369.          this.startLevel();
  370.       }
  371.       
  372.       private function startLevel(param1:int = -1) : void
  373.       {
  374.          var noMap:int = param1;
  375.          if(noMap != -1 && noMap != this.mapNum)
  376.          {
  377.             this.mapNum = noMap;
  378.             this.createLevel();
  379.          }
  380.          if(this.mapNum == 2)
  381.          {
  382.             this.demos.gotoAndStop("D2");
  383.             this.demos.visible = true;
  384.             this.demos.parent = this._container.clip;
  385.             this.SCORE["CLIP_TEMPS"].visible = false;
  386.             game.commentPlay({
  387.                "code":"DEMO_N2",
  388.                "callback":function():void
  389.                {
  390.                   startLevelSuite();
  391.                }
  392.             });
  393.          }
  394.          else if(this.mapNum == 3)
  395.          {
  396.             this.demos.gotoAndStop("D3_01");
  397.             this.demos.visible = true;
  398.             this.demos.parent = this._container.clip;
  399.             this.SCORE.setPoints("temps",100);
  400.             this.SCORE["CLIP_TEMPS"].visible = true;
  401.             game.commentPlay({
  402.                "code":"DEMO_N3_01",
  403.                "callback":function():void
  404.                {
  405.                   demos.gotoAndStop("D3_02");
  406.                   game.commentPlay({
  407.                      "code":"DEMO_N3_02",
  408.                      "callback":function():void
  409.                      {
  410.                         startLevelSuite();
  411.                      }
  412.                   });
  413.                }
  414.             });
  415.          }
  416.          else
  417.          {
  418.             this.SCORE["CLIP_TEMPS"].visible = false;
  419.             this.startLevelSuite();
  420.          }
  421.          this.perso.jumping = 0;
  422.          this.perso.isDown = false;
  423.          this.controller.enabled = true;
  424.       }
  425.       
  426.       private function startLevelSuite() : void
  427.       {
  428.          this.demos.parent = null;
  429.          this.demos.gotoAndStop(1);
  430.          this.allReset();
  431.          this.startTime = this.lastTime = getTimer();
  432.          this.elapsedTime = this.delayTime = 0;
  433.          this.perso.jumpScale = this.mapNum == 3 ? 0.6 : 1;
  434.          this.perso.refY = this.perso.restY;
  435.          this.perso.gotoAndStop("E1");
  436.          game.mainTimer.start();
  437.          this.mainLoop.start();
  438.          this.trailerRunning = true;
  439.          this.perso.enabled = false;
  440.          game.noisePlayIfNotPlaying(this.noises["B_COURT"]);
  441.          this.controller.addEventListener(GenericEvent.SELECT,this.onControllerAction);
  442.          this._container.enabled = false;
  443.          this.controller.enabled = true;
  444.       }
  445.       
  446.       private function onControllerAction(param1:GenericEvent) : void
  447.       {
  448.          if(param1.toolType == "38" && this.perso.isDown != true)
  449.          {
  450.             this.controller.enabled = false;
  451.             this.perso.enabled = false;
  452.             this._container.enabled = false;
  453.             this.perso.gotoAndStop("E4");
  454.             this.perso.jumping = "up";
  455.             this.perso.typeJump = !!this.perso.inDistancePasserelleJump ? 2 : 1;
  456.             this.perso.anim = this.perso.getChildByName("CLIP") as MovieClip;
  457.             this.perso.topJumpTimeTemp = 0;
  458.             this.perso.IMAGE = 1;
  459.             this.perso.anim.gotoAndStop(1);
  460.             this.noises["B_COURT"].stop();
  461.             game.noisePlay({"code":"B_SAUT"});
  462.          }
  463.          else if(param1.toolType == "40" && this.perso.jumping == 0 && this.perso.isDown != true)
  464.          {
  465.             this.perso.enabled = false;
  466.             this._container.enabled = false;
  467.             this.perso.isDown = true;
  468.             this.perso.gotoAndStop("E3");
  469.             this.noises["B_COURT"].stop();
  470.             game.noisePlay({"code":"B_BAISSE"});
  471.          }
  472.          else if(param1.toolType == null)
  473.          {
  474.             if(this.perso.isDown)
  475.             {
  476.                this.perso.isDown = false;
  477.                this.perso.gotoAndStop("E1");
  478.             }
  479.          }
  480.       }
  481.       
  482.       private function createLevel() : void
  483.       {
  484.          this.elementsActor.destroyChildren();
  485.          this._elements.length = 0;
  486.          this.getElementsList();
  487.       }
  488.       
  489.       private function loop(param1:TimerChild) : void
  490.       {
  491.          if(!this.mainLoop.running)
  492.          {
  493.             return;
  494.          }
  495.          this.delayTime = getTimer() - this.lastTime;
  496.          this.lastTime = getTimer();
  497.          this.elapsedTime = this.lastTime - this.startTime;
  498.          this.trailerMove();
  499.          this.persoMove();
  500.       }
  501.       
  502.       private function trailerMove() : void
  503.       {
  504.          if(!this.trailerRunning)
  505.          {
  506.             return;
  507.          }
  508.          this.plans.foreach(function(param1:*):void
  509.          {
  510.             if(param1.bitmap.x + param1.speed + param1.bitmap.width <= param1.initialBounds.x + param1.bitmap.width / 2)
  511.             {
  512.                param1.bitmap.x = param1.initialBounds.x;
  513.             }
  514.             else
  515.             {
  516.                param1.bitmap.x += param1.speed * perso.jumpSpeedXTemp;
  517.             }
  518.          });
  519.          this.trailerClip.x += this.plans["CHEMIN"].speed * this.perso.jumpSpeedXTemp;
  520.          var i:int = 0;
  521.          while(i < this._elements.length)
  522.          {
  523.             if(this._elements[i].passed == false && this._elements[i].launched == true && Math.abs(this.trailerClip.x) - 400 > this._elements[i].x * 600 / 218)
  524.             {
  525.                this._elements[i].actor.stop();
  526.                this.trailerClip.removeChild(this._elements[i].clip);
  527.                this._elements[i].passed = true;
  528.             }
  529.             else if(this._elements[i].passed == false && this._elements[i].launched == false && Math.abs(this.trailerClip.x) + 1400 > this._elements[i].x * 600 / 218)
  530.             {
  531.                if(this._elements[i].infos.type == "finish")
  532.                {
  533.                   this.trailerClip.addChild(this._elements[i].clip);
  534.                   this._elements[i].launched = true;
  535.                   this.endFlag = this._elements[i];
  536.                   this.endFlag.globalX = this._container.getObjectCoordToLocal(this._elements[i].clip).x;
  537.                   return;
  538.                }
  539.                if(this._elements[i].infos.type == "decor")
  540.                {
  541.                   this.trailerClip.addChildAt(this._elements[i].clip,0);
  542.                }
  543.                else
  544.                {
  545.                   this.trailerClip.addChild(this._elements[i].clip);
  546.                }
  547.                this._elements[i].actor.gotoAndStop("E1");
  548.                this._elements[i].launched = true;
  549.             }
  550.             else if(this._elements[i].passed == false && this._elements[i].launched == true && this._elements[i].infos.type == "ennemy_aerien")
  551.             {
  552.                this._elements[i].clip.x -= 5;
  553.             }
  554.             i++;
  555.          }
  556.       }
  557.       
  558.       private function persoInit() : void
  559.       {
  560.          this.perso = addActor({
  561.             "type":ActorClip,
  562.             "mc":new Perso(),
  563.             "parent":this._container.clip
  564.          });
  565.          this.perso.name = "PERSO";
  566.          this.perso.bringToFront();
  567.          var onClickBitmap:Function = function():void
  568.          {
  569.             perso.enabled = false;
  570.             _container.enabled = false;
  571.             perso.gotoLabel("E4");
  572.             perso.jumping = "up";
  573.             perso.topJumpTimeTemp = 0;
  574.             perso.typeJump = !!perso.inDistancePasserelleJump ? 2 : 1;
  575.             perso.IMAGE = 1;
  576.          };
  577.          var onClickActorClip:Function = function(param1:ActorClip):void
  578.          {
  579.             perso.enabled = false;
  580.             _container.enabled = false;
  581.             perso.gotoAndStop("E4");
  582.             perso.jumping = "up";
  583.             perso.typeJump = !!perso.inDistancePasserelleJump ? 2 : 1;
  584.             perso.anim = perso.getChildByName("CLIP") as MovieClip;
  585.             perso.topJumpTimeTemp = 0;
  586.             perso.IMAGE = 1;
  587.             perso.anim.gotoAndStop(1);
  588.             noises["B_COURT"].stop();
  589.             game.noisePlay({"code":"B_SAUT"});
  590.          };
  591.          this.perso.initAs();
  592.          this.perso.enabled = false;
  593.          this._container.enabled = false;
  594.          this.perso.restX = 103 * this.ratio.x;
  595.          this.perso.restY = 190 * this.ratio.y;
  596.          this.perso.x = this.perso.restX;
  597.          this.perso.y = this.perso.restY;
  598.          this.perso.gotoAndStop("E1");
  599.          this.perso.jumping = "0";
  600.          this.perso.jumpHeightInAsset = 100;
  601.          this.perso.jumpHeight = this.perso.jumpHeightInAsset * this.ratio.y;
  602.          this.perso.topJumpTime = 40;
  603.          this.perso.topJumpTimeTemp = 0;
  604.          this.perso.speed = 0.3;
  605.          this.perso.IMAGE = 1;
  606.          this.perso.jumpSpeedX = 1;
  607.          this.perso.jumpSpeedY = -10;
  608.          this.perso.jumpSpeedXTemp = 1;
  609.          this.perso.jumpSpeedYTemp = -1;
  610.          this.perso.restScale = this.perso.clip.scaleX;
  611.          this.perso.jumpScale = this.mapNum == 3 ? 0.6 : 1;
  612.          this.perso.jumpScaleTemp = 1;
  613.          var nb:Number = (this.perso.restY - this.perso.y) / this.perso.jumpSpeedYTemp;
  614.          var dx:Number = nb * this.plans["CHEMIN"].speed * this.perso.jumpSpeedXTemp;
  615.          this.perso.distanceJump = 100 * this.ratio.x;
  616.       }
  617.       
  618.       private function persoAdaptScaleFromY() : void
  619.       {
  620.          if(this.perso.refY != this.perso.restY || this.perso.typeJump == 1)
  621.          {
  622.             return;
  623.          }
  624.          var _loc1_:Number = 1;
  625.          var _loc2_:Number = (this.perso.restY - this.perso.y) / this.perso.jumpHeight;
  626.          _loc1_ = 1 - (1 - this.perso.jumpScale) * _loc2_;
  627.          this.perso.clip.scaleX = this.perso.clip.scaleY = this.perso.restScale * _loc1_;
  628.       }
  629.       
  630.       private function persoMove() : void
  631.       {
  632.          var pt:Point = null;
  633.          var tempElement:* = undefined;
  634.          this.SCORE.setPoints("temps",this.SCORE.getPoints("temps") + this.SCORE["CLIP_TEMPS"].speed);
  635.          this.SCORE["CLIP_TEMPS"].gotoAndStop(100 - Math.floor(this.SCORE.getPoints("temps")));
  636.          if(this.mapNum == 3 && this.SCORE.getPoints("temps") < 0)
  637.          {
  638.             this.onFail2();
  639.             return;
  640.          }
  641.          var origin:Point = this.perso.getPos();
  642.          this.marker1.x = origin.x;
  643.          this.marker1.y = origin.y;
  644.          if(!this.mainLoop.running)
  645.          {
  646.             return;
  647.          }
  648.          if(this.perso.isDown)
  649.          {
  650.             if(this.perso.x > this._container.getObjectCoordToLocal(this.endFlag.clip).x)
  651.             {
  652.                this.mainLoop.stop();
  653.             }
  654.          }
  655.          else if(this.perso.jumping == "0")
  656.          {
  657.             if(this.perso.currentLabel != "E1")
  658.             {
  659.                this.perso.gotoAndStop("E1");
  660.             }
  661.             game.noisePlayIfNotPlaying(this.noises["B_COURT"]);
  662.             this.perso.enabled = false;
  663.             this._container.enabled = false;
  664.             this.controller.enabled = true;
  665.             if(!(this.perso.isInPasserelleZone == true && this.perso.onPasserelleZone == true))
  666.             {
  667.                this.perso.onPasserelleZone = false;
  668.                this.perso.refY = this.perso.y = this.perso.restY;
  669.                this.perso.clip.scaleX = this.perso.clip.scaleY = this.perso.restScale;
  670.             }
  671.             this.perso.jumpSpeedXTemp = 1;
  672.             this.perso.jumpSpeedYTemp = -1;
  673.             if(this.perso.x > this._container.getObjectCoordToLocal(this.endFlag.clip).x)
  674.             {
  675.                this.mainLoop.stop();
  676.             }
  677.          }
  678.          else if(this.perso.jumping == "up")
  679.          {
  680.             this.perso.jumpHeightTemp = this.perso.refY == this.perso.restY ? this.perso.jumpHeight : this.perso.jumpHeight * this.perso.jumpScale;
  681.             this.perso.enabled = false;
  682.             this._container.enabled = false;
  683.             this.controller.enabled = false;
  684.             this.perso.onPasserelleZone = false;
  685.             if(this.perso.y < this.perso.refY - this.perso.jumpHeightTemp * 0.3)
  686.             {
  687.                if(this.perso.anim.currentLabel != "TOP")
  688.                {
  689.                   this.perso.anim.gotoAndStop("TOP");
  690.                }
  691.             }
  692.             else if(this.perso.y < this.perso.refY - this.perso.jumpHeightTemp * 0.2)
  693.             {
  694.                if(this.perso.anim.currentLabel != "UP2")
  695.                {
  696.                   this.perso.anim.gotoAndStop("UP2");
  697.                }
  698.             }
  699.             else if(this.perso.anim.currentLabel != "UP")
  700.             {
  701.                this.perso.anim.gotoAndStop("UP");
  702.             }
  703.             this.perso.jumpSpeedXTemp = this.perso.jumpSpeedX;
  704.             this.perso.jumpSpeedYTemp = this.perso.refY == this.perso.restY ? this.perso.jumpSpeedY : this.perso.jumpSpeedY * this.perso.jumpScale;
  705.             this.persoAdaptScaleFromY();
  706.             this.perso.y += this.perso.jumpSpeedYTemp;
  707.             if(this.perso.y < this.perso.refY - this.perso.jumpHeightTemp)
  708.             {
  709.                this.perso.jumping = "top";
  710.             }
  711.          }
  712.          else if(this.perso.jumping == "top")
  713.          {
  714.             this.perso.enabled = false;
  715.             this._container.enabled = false;
  716.             this.controller.enabled = false;
  717.             this.perso.onPasserelleZone = false;
  718.             if(this.perso.anim.currentLabel != "TOP")
  719.             {
  720.                this.perso.anim.gotoAndStop("TOP");
  721.             }
  722.             this.perso.topJumpTimeTemp += 1;
  723.             if(this.perso.topJumpTimeTemp > this.perso.topJumpTime)
  724.             {
  725.                this.perso.jumping = "down";
  726.             }
  727.          }
  728.          else if(this.perso.jumping == "down")
  729.          {
  730.             this.perso.enabled = false;
  731.             this._container.enabled = false;
  732.             this.controller.enabled = false;
  733.             this.perso.onPasserelleZone = false;
  734.             this.perso.inDistancePasserelleJump = false;
  735.             if(this.perso.y < this.perso.refY - this.perso.jumpHeight * 0.6)
  736.             {
  737.                if(this.perso.anim.currentLabel != "TOP")
  738.                {
  739.                   this.perso.anim.gotoAndStop("TOP");
  740.                }
  741.             }
  742.             else if(this.perso.y < this.perso.refY - this.perso.jumpHeight * 0)
  743.             {
  744.                if(this.perso.anim.currentLabel != "DOWN2")
  745.                {
  746.                   this.perso.anim.gotoAndStop("DOWN2");
  747.                }
  748.             }
  749.             this.perso.jumpSpeedXTemp = this.perso.jumpSpeedX;
  750.             this.perso.jumpSpeedYTemp = this.perso.refY == this.perso.restY ? this.perso.jumpSpeedY : this.perso.jumpSpeedY * this.perso.jumpScale;
  751.             this.persoAdaptScaleFromY();
  752.             this.perso.y -= this.perso.jumpSpeedYTemp;
  753.             if(this.perso.y >= this.perso.refY)
  754.             {
  755.                if(this.perso.refY != this.perso.restY)
  756.                {
  757.                   this.perso.refY = this.perso.restY;
  758.                }
  759.                else
  760.                {
  761.                   this.perso.jumping = "0";
  762.                }
  763.             }
  764.             else if(this.perso.isInPasserelleZone)
  765.             {
  766.                pt = new Point(0,this.perso.Passerelle.actor.getChildByName("FLOOR").y);
  767.                pt = this.perso.parent.globalToLocal(this.perso.Passerelle.actor.clip.localToGlobal(pt));
  768.                if(this.perso.y > pt.y - 20 && this.perso.y <= pt.y)
  769.                {
  770.                   this.perso.refY = this.perso.y = pt.y;
  771.                   this.perso.onPasserelleZone = true;
  772.                   this.perso.jumping = "0";
  773.                }
  774.             }
  775.          }
  776.          this.perso.inDistancePasserelleJump = false;
  777.          this.perso.isInPasserelleZone = false;
  778.          var i:int = 0;
  779.          for(; i < this._elements.length; i++)
  780.          {
  781.             if(this._elements[i].infos.type == "Passerelle" && this.isCollided(this._elements[i]))
  782.             {
  783.                this.perso.isInPasserelleZone = true;
  784.                this.perso.Passerelle = this._elements[i];
  785.             }
  786.             if(this._elements[i].hitted != true && this._elements[i].passed == false && this._elements[i].launched == true && this.isCollided(this._elements[i]))
  787.             {
  788.                if(this._elements[i].infos.type != "Passerelle")
  789.                {
  790.                   this.perso.enabled = false;
  791.                   this._container.enabled = false;
  792.                   this.controller.enabled = false;
  793.                   this._elements[i].hitted = true;
  794.                   tempElement = this._elements[i].actor;
  795.                   if(this._elements[i].infos.type == "finish")
  796.                   {
  797.                      this.trailerClip.removeChild(this._elements[i].clip);
  798.                      this.onSucces();
  799.                      return;
  800.                   }
  801.                   if(this._elements[i].infos.type != "friandise")
  802.                   {
  803.                      if(this._elements[i].infos.type != "energy")
  804.                      {
  805.                         if(this._elements[i].infos.type != "decor")
  806.                         {
  807.                            if(this._elements[i].infos.type != "Passerelle")
  808.                            {
  809.                               this.mainLoop.stop();
  810.                               this.SCORE.addPoints("vie",this._elements[i].infos.points);
  811.                               tempElement.gotoAndStop("E2");
  812.                               game.noisePlay({"code":"B_OUILLE"});
  813.                            }
  814.                            continue;
  815.                            this.perso.gotoAndStop("E2",{"labelLastCallback":function():void
  816.                            {
  817.                               tempElement.visible = false;
  818.                               perso.gotoAndStop("E1");
  819.                               perso.jumping = "0";
  820.                               perso.isDown = false;
  821.                               mainLoop.start();
  822.                               perso.enabled = false;
  823.                               _container.enabled = false;
  824.                               controller.enabled = true;
  825.                               scoreRefresh();
  826.                            }});
  827.                         }
  828.                         continue;
  829.                      }
  830.                      game.noisePlay({"code":"B_ENERGIE"});
  831.                      this.SCORE.addPoints("temps",25);
  832.                      tempElement.gotoAndStop("E2",{"labelLastCallback":function():void
  833.                      {
  834.                         tempElement.visible = false;
  835.                         perso.enabled = false;
  836.                         _container.enabled = false;
  837.                         controller.enabled = true;
  838.                         scoreRefresh();
  839.                      }});
  840.                   }
  841.                   this.controller.enabled = true;
  842.                }
  843.                continue;
  844.                game.noisePlay({"code":"B_MIAM"});
  845.                this.SCORE.addPoints("fleur",this._elements[i].infos.points);
  846.                tempElement.gotoAndStop("E2",{"labelLastCallback":function():void
  847.                {
  848.                   tempElement.visible = false;
  849.                   perso.enabled = false;
  850.                   _container.enabled = false;
  851.                   controller.enabled = true;
  852.                   scoreRefresh();
  853.                }});
  854.                continue;
  855.                continue;
  856.                return;
  857.             }
  858.          }
  859.          if(this.perso.isInPasserelleZone == false && this.perso.onPasserelleZone == true)
  860.          {
  861.             this.perso.refY = this.perso.restY;
  862.             this.perso.onPasserelleZone = false;
  863.             this.perso.jumping = "down";
  864.          }
  865.       }
  866.       
  867.       private function isCollided(param1:*) : Boolean
  868.       {
  869.          var _loc5_:int = 0;
  870.          if(param1.infos.type == "finish")
  871.          {
  872.             return this.perso.clip.hitTestObject(param1.clip);
  873.          }
  874.          var _loc2_:Rectangle = param1.actor.getBounds(this.perso.parent);
  875.          var _loc3_:Rectangle = param1.actor.getBounds(stage);
  876.          var _loc4_:Rectangle = this.perso.clip.getBounds(this.perso.parent);
  877.          if(param1.infos.type == "Passerelle" && _loc2_.x - _loc4_.right < this.perso.distanceJump / 2)
  878.          {
  879.             this.perso.inDistancePasserelleJump = true;
  880.          }
  881.          if(param1.infos.type == "Passerelle" && _loc4_.right > _loc2_.x && _loc4_.x < _loc2_.x + _loc2_.width)
  882.          {
  883.             return true;
  884.          }
  885.          _loc5_ = 1;
  886.          while(_loc5_ <= 11)
  887.          {
  888.             this.pt2.x = this.perso.getChildByName("CLIP.REP" + GlobalesFunctions.gimme2digits(_loc5_)).x;
  889.             this.pt2.y = this.perso.getChildByName("CLIP.REP" + GlobalesFunctions.gimme2digits(_loc5_)).y;
  890.             this.pt2 = this.perso.clip.CLIP.localToGlobal(this.pt2);
  891.             if(param1.actor.clip.hitTestPoint(this.pt2.x,this.pt2.y,true))
  892.             {
  893.                if(param1.infos.type == "decor" || param1.infos.type == "Passerelle")
  894.                {
  895.                   return false;
  896.                }
  897.                return true;
  898.             }
  899.             _loc5_++;
  900.          }
  901.          return false;
  902.       }
  903.       
  904.       private function stop() : void
  905.       {
  906.          this.controller.removeEventListener(GenericEvent.SELECT,this.onControllerAction);
  907.          this.mainLoop.stop();
  908.          game.mainTimer.stop();
  909.          game.noiseStop();
  910.       }
  911.       
  912.       private function allReset() : void
  913.       {
  914.          this.objectsReset();
  915.       }
  916.       
  917.       private function scoreReset() : void
  918.       {
  919.          this.SCORE.setPoints("fleur",0);
  920.          if(this.mapNum == 3)
  921.          {
  922.             this.SCORE.setPoints("pomme",0);
  923.          }
  924.          this.SCORE.setPoints("vie",3);
  925.          this.SCORE.setPoints("temps",100);
  926.          this.scoreRefresh();
  927.       }
  928.       
  929.       private function scoreRefresh() : void
  930.       {
  931.          this.SCORE["TXT_FLEURS"].text = GlobalesFunctions.gimme2digits(this.SCORE.getPoints("fleur"));
  932.          if(this.SCORE.getPoints("temps") >= 100)
  933.          {
  934.             this.SCORE.setPoints("temps",100);
  935.          }
  936.          if(this.SCORE.getPoints("temps") < 0)
  937.          {
  938.             this.SCORE.setPoints("temps",0);
  939.          }
  940.          this.SCORE["CLIP_TEMPS"].gotoAndStop(Math.floor(this.SCORE.getPoints("temps")));
  941.          var _loc1_:int = 1;
  942.          while(_loc1_ <= 3)
  943.          {
  944.             if(_loc1_ <= this.SCORE.getPoints("vie"))
  945.             {
  946.                this.SCORE.getActor("VIE_0" + _loc1_).gotoAndStop("E1");
  947.             }
  948.             else
  949.             {
  950.                this.SCORE.getActor("VIE_0" + _loc1_).gotoAndStop("E2");
  951.             }
  952.             _loc1_++;
  953.          }
  954.          if(this.SCORE.getPoints("vie") == 0)
  955.          {
  956.             this.onFail();
  957.          }
  958.          else if(this.mapNum == 3 && this.SCORE.getPoints("temps") <= 0)
  959.          {
  960.             this.onFail2();
  961.          }
  962.       }
  963.       
  964.       private function onSucces() : void
  965.       {
  966.          this.stop();
  967.          if(this.level == 2 && this.mapNum < 2)
  968.          {
  969.             this.startLevel(this.mapNum + 1);
  970.          }
  971.          else if(this.level == 3 && this.mapNum < 3)
  972.          {
  973.             this.startLevel(this.mapNum + 1);
  974.          }
  975.          else
  976.          {
  977.             game.memo.setValue("RUBRIQUE.jeu3.ok",true);
  978.             game.memo.setValue("RUBRIQUE.jeu4.unlock",true);
  979.             this.SCORE.totalScoreCalculAndShow();
  980.             this.perso.gotoAndStop("FIN");
  981.             this.perso.visible = false;
  982.             this.animSucces.play(1,this.animSucces.totalFrames);
  983.             this.animSucces.bringToFront();
  984.             this.animSucces.visible = true;
  985.             this._container.enabled = false;
  986.             this._container.clip.mouseChildren = true;
  987.             game.commentPlay({
  988.                "code":"SUCCES",
  989.                "callback":function():void
  990.                {
  991.                   btRejouer.visible = true;
  992.                   btRejouer.bringToFront();
  993.                   btRejouer.enabled = true;
  994.                }
  995.             });
  996.          }
  997.       }
  998.       
  999.       private function onFail() : void
  1000.       {
  1001.          this.stop();
  1002.          this.SCORE.totalScoreAdd(this.SCORE.levelPoints.jeuEchec);
  1003.          this.perso.y = this.perso.restY;
  1004.          this.perso.clip.scaleX = this.perso.clip.scaleY = this.perso.restScale;
  1005.          this.perso.gotoAndStop("E5");
  1006.          game.commentPlay({
  1007.             "code":"ECHEC",
  1008.             "callback":function():void
  1009.             {
  1010.                perso.gotoAndStop("E1");
  1011.                scoreReset();
  1012.                startLevel(1);
  1013.             }
  1014.          });
  1015.       }
  1016.       
  1017.       private function onFail2() : void
  1018.       {
  1019.          this.stop();
  1020.          this.controller.enabled = false;
  1021.          this.perso.y = this.perso.restY;
  1022.          this.perso.clip.scaleX = this.perso.clip.scaleY = this.perso.restScale;
  1023.          this.perso.gotoAndStop("E5");
  1024.          game.commentPlay({
  1025.             "code":"ENERGIE",
  1026.             "callback":function():void
  1027.             {
  1028.                perso.gotoAndStop("E1");
  1029.                scoreReset();
  1030.                startLevel(1);
  1031.             }
  1032.          });
  1033.       }
  1034.       
  1035.       override protected function _destroy() : void
  1036.       {
  1037.          this.stop();
  1038.          this._container.enabled = false;
  1039.          this.controller.removeEventListener(GenericEvent.SELECT,this.onControllerAction);
  1040.          super._destroy();
  1041.       }
  1042.    }
  1043. }
  1044.