home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 161 / MOBICLIC161.ISO / pc / DATA / DSS161 / DSS161_00 / DSS161_00.swf / scripts / dss161 / engineaddons / timelines / TimelineLinear.as < prev   
Text File  |  2014-01-15  |  23KB  |  615 lines

  1. package dss161.engineaddons.timelines
  2. {
  3.    import com.milanpresse.engine.Engine;
  4.    import com.milanpresse.engine.managers.TimelineManager;
  5.    import com.milanpresse.engine.medias.MediaSon;
  6.    import com.milanpresse.engine.typeargument.CommentObject;
  7.    import com.milanpresse.tools.GlobalesFunctions;
  8.    import flash.display.DisplayObject;
  9.    import flash.display.MovieClip;
  10.    import flash.display.Sprite;
  11.    import flash.events.Event;
  12.    import flash.events.MouseEvent;
  13.    
  14.    public class TimelineLinear extends Timeline
  15.    {
  16.        
  17.       
  18.       private var _listeMovieBeforeGTAPU:Vector.<DisplayObject>;
  19.       
  20.       private var labelsCallback:Object;
  21.       
  22.       private var _levelFunction;
  23.       
  24.       private var clipZap:Sprite = null;
  25.       
  26.       private var GotoAndPlayUntilParams:Object;
  27.       
  28.       public var isPlayingGPUntil:Boolean = false;
  29.       
  30.       private var animIntern:Timeline = null;
  31.       
  32.       private var commentGPUntil:MediaSon = null;
  33.       
  34.       public var onLabelEnd:Function = null;
  35.       
  36.       public function TimelineLinear(param1:MovieClip, param2:Engine, param3:*, param4:TimelineManager, param5:Object = null)
  37.       {
  38.          this._listeMovieBeforeGTAPU = new Vector.<DisplayObject>();
  39.          super(param1,param4,param2);
  40.          this.labelsCallback = param5;
  41.          _engine = param2;
  42.          this._levelFunction = param3;
  43.       }
  44.       
  45.       private function clipZapShow() : void
  46.       {
  47.          this.clipZap = GlobalesFunctions.createRectangle({
  48.             "color":65280,
  49.             "alpha":0
  50.          });
  51.          this.clipZap.addEventListener(MouseEvent.CLICK,function():void
  52.          {
  53.             nextLabel();
  54.          });
  55.          _engine.config.layers["content"].addChild(this.clipZap);
  56.          this.clipZap.visible = true;
  57.       }
  58.       
  59.       private function clipZapHide() : void
  60.       {
  61.          if(this.clipZap != null)
  62.          {
  63.             this.clipZap.parent.removeChild(this.clipZap);
  64.             this.clipZap = null;
  65.          }
  66.       }
  67.       
  68.       override public function Stop() : void
  69.       {
  70.          super.Stop();
  71.          if(this.animIntern != null)
  72.          {
  73.             this.animIntern.destroy();
  74.             this.animIntern = null;
  75.          }
  76.          if(this.commentGPUntil != null)
  77.          {
  78.             this.commentGPUntil = null;
  79.             _engine.stopComment();
  80.          }
  81.          if(this.animIntern != null)
  82.          {
  83.             this.animIntern.Stop();
  84.             this.animIntern = null;
  85.          }
  86.          this.isPlayingGPUntil = false;
  87.       }
  88.       
  89.       override public function GotoAndPlayUntil(param1:Object) : void
  90.       {
  91.          var theMovie:MovieClip = null;
  92.          var framePlay:int = 0;
  93.          var frameStop:int = 0;
  94.          var isOK:Boolean = false;
  95.          var frameContructedListener:Function = null;
  96.          var enterFrameListener:Function = null;
  97.          var p:Object = param1;
  98.          this.Stop();
  99.          this.isPlayingGPUntil = true;
  100.          this.GotoAndPlayUntilParams = p;
  101.          this._listeMovieBeforeGTAPU = this.initListeMovie();
  102.          legendesMediasHide();
  103.          if(p.mc == undefined)
  104.          {
  105.             theMovie = _movie;
  106.             removeListeners(_movie);
  107.          }
  108.          else
  109.          {
  110.             theMovie = p.mc;
  111.          }
  112.          var pPlay:Boolean = false;
  113.          p.callback = p.callback == undefined ? null : p.callback;
  114.          if(this._levelFunction.hasOwnProperty(["onLabelExit"]) && this._levelFunction.onLabelExit != null)
  115.          {
  116.             this._levelFunction["onLabelExit"]({"label":_movie.currentLabel});
  117.          }
  118.          if(typeof p.labelPlay == "string")
  119.          {
  120.             framePlay = turnLabelIntoFrame(theMovie,p.labelPlay);
  121.          }
  122.          else
  123.          {
  124.             framePlay = p.labelPlay;
  125.          }
  126.          if(p.labelStop !== undefined)
  127.          {
  128.             if(typeof p.labelStop == "string")
  129.             {
  130.                if(p.labelPlay == undefined)
  131.                {
  132.                   if(this._levelFunction.hasOwnProperty(["beforeLabel" + p.labelStop]) == true)
  133.                   {
  134.                      this._levelFunction["beforeLabel" + p.labelStop]();
  135.                   }
  136.                }
  137.                frameStop = turnLabelIntoFrame(theMovie,p.labelStop);
  138.             }
  139.             else
  140.             {
  141.                frameStop = p.labelStop;
  142.             }
  143.          }
  144.          else if(p.beforeLabelStop !== undefined)
  145.          {
  146.             frameStop = turnLabelIntoFrame(theMovie,p.beforeLabelStop);
  147.          }
  148.          else
  149.          {
  150.             frameStop = theMovie.totalFrames;
  151.          }
  152.          isOK = false;
  153.          frameContructedListener = function():void
  154.          {
  155.             var _loc1_:String = null;
  156.             var _loc2_:String = null;
  157.             var _loc3_:Array = null;
  158.             var _loc4_:int = 0;
  159.             var _loc5_:* = null;
  160.             var _loc6_:String = null;
  161.             var _loc7_:MovieClip = null;
  162.             var _loc8_:MovieClip = null;
  163.             var _loc9_:String = null;
  164.             var _loc10_:int = 0;
  165.             if(isPlayingGPUntil == false)
  166.             {
  167.                return;
  168.             }
  169.             isOK = false;
  170.             if(p.labelStop !== undefined || p.beforeLabelStop !== undefined)
  171.             {
  172.                if(theMovie.currentFrame == frameStop)
  173.                {
  174.                   isOK = true;
  175.                }
  176.             }
  177.             else
  178.             {
  179.                isOK = true;
  180.             }
  181.             if(isOK)
  182.             {
  183.                if(p.labelPlay == undefined)
  184.                {
  185.                   legendesMediasShow();
  186.                }
  187.                theMovie.functionListener = undefined;
  188.                theMovie.removeEventListener(Event.FRAME_CONSTRUCTED,frameContructedListener);
  189.                theMovie.stop();
  190.                _timelineManager.addMovie(theMovie);
  191.                if(typeof p.callback == "function")
  192.                {
  193.                   p.callback();
  194.                }
  195.                else
  196.                {
  197.                   _loc1_ = p.labelStop;
  198.                   if(labelsCallback !== null)
  199.                   {
  200.                      _loc2_ = "";
  201.                      if(labelsCallback[_loc1_] !== null && labelsCallback[_loc1_] is String)
  202.                      {
  203.                         _loc2_ = labelsCallback[_loc1_];
  204.                      }
  205.                      if(isPlayingGPUntil == false)
  206.                      {
  207.                         return;
  208.                      }
  209.                      if(labelsCallback[_loc1_] !== undefined && _loc2_ == "")
  210.                      {
  211.                         labelsCallback[_loc1_]();
  212.                      }
  213.                      else
  214.                      {
  215.                         if(isPlayingGPUntil == false)
  216.                         {
  217.                            return;
  218.                         }
  219.                         if(_levelFunction.hasOwnProperty(["onLabelEnter"]) && _levelFunction.onLabelEnter != null)
  220.                         {
  221.                            _levelFunction["onLabelEnter"]({"label":_movie.currentLabel});
  222.                         }
  223.                         if(isPlayingGPUntil == false)
  224.                         {
  225.                            return;
  226.                         }
  227.                         if(_levelFunction.hasOwnProperty(["label" + _loc1_]) == true)
  228.                         {
  229.                            _levelFunction["label" + _loc1_]();
  230.                         }
  231.                         if(isPlayingGPUntil == false)
  232.                         {
  233.                            return;
  234.                         }
  235.                         switch(_loc1_.split("_")[0])
  236.                         {
  237.                            case "WAIT":
  238.                               _loc3_ = _loc1_.split("_");
  239.                               _loc4_ = _loc3_.length;
  240.                               _loc5_ = "";
  241.                               _loc10_ = 1;
  242.                               while(_loc10_ < _loc4_)
  243.                               {
  244.                                  _loc5_ += _loc3_[_loc10_];
  245.                                  if(_loc10_ < _loc4_ - 1)
  246.                                  {
  247.                                     _loc5_ += "_";
  248.                                  }
  249.                                  _loc10_++;
  250.                               }
  251.                               _loc6_ = GlobalesFunctions.deleteSpaceAtStringEnd(_loc5_);
  252.                               _loc7_ = theMovie[_loc6_];
  253.                               if(_loc7_ !== null)
  254.                               {
  255.                                  animIntern = new Timeline(_loc7_,_timelineManager);
  256.                                  animIntern.GotoAndPlayUntil({
  257.                                     "labelPlay":1,
  258.                                     "labelStop":_loc7_.totalFrames,
  259.                                     "callback":nextLabel
  260.                                  });
  261.                                  clipZapShow();
  262.                               }
  263.                               else
  264.                               {
  265.                                  nextLabel();
  266.                               }
  267.                               break;
  268.                            case "PLAY":
  269.                               break;
  270.                            case "ATTENTE":
  271.                               break;
  272.                            default:
  273.                               _loc8_ = theMovie["anim"];
  274.                               if(_loc8_ == null)
  275.                               {
  276.                                  _loc8_ = theMovie["anim_"];
  277.                               }
  278.                               if(_loc1_.substr(0,1) == "_")
  279.                               {
  280.                                  _loc9_ = GlobalesFunctions.deleteSpaceAtStringEnd(_loc1_.slice(1,_loc1_.length));
  281.                               }
  282.                               else
  283.                               {
  284.                                  _loc9_ = GlobalesFunctions.deleteSpaceAtStringEnd(_loc1_);
  285.                               }
  286.                               if(_loc2_ !== "prioAnim")
  287.                               {
  288.                                  if(_loc1_.search(/^_/) != -1)
  289.                                  {
  290.                                     if(_loc8_ !== null)
  291.                                     {
  292.                                        animIntern = new Timeline(_loc8_,_timelineManager);
  293.                                        animIntern.GotoAndPlayUntil({
  294.                                           "labelPlay":1,
  295.                                           "labelStop":_loc8_.totalFrames,
  296.                                           "callback":animFinished
  297.                                        });
  298.                                        commentGPUntil = _engine.playComment(new CommentObject({
  299.                                           "code":_loc9_,
  300.                                           "callback":commentFinished,
  301.                                           "zapBlock":"NOZAP_NOBLOCK"
  302.                                        }));
  303.                                        clipZapShow();
  304.                                     }
  305.                                     else
  306.                                     {
  307.                                        commentGPUntil = _engine.playComment(new CommentObject({
  308.                                           "code":_loc9_,
  309.                                           "callback":nextLabel
  310.                                        }));
  311.                                     }
  312.                                  }
  313.                                  else if(_loc8_ !== null)
  314.                                  {
  315.                                     animIntern = new Timeline(_loc8_,_timelineManager);
  316.                                     Performer.dico[this] = this.toString() + ", " + _movie.name;
  317.                                     animIntern.GotoAndPlayUntil({
  318.                                        "labelPlay":1,
  319.                                        "labelStop":_loc8_.totalFrames,
  320.                                        "callback":nextLabel
  321.                                     });
  322.                                  }
  323.                                  else
  324.                                  {
  325.                                     nextLabel();
  326.                                  }
  327.                               }
  328.                               else if(_loc8_ !== null)
  329.                               {
  330.                                  animIntern = new Timeline(_loc8_,_timelineManager);
  331.                                  animIntern.GotoAndPlayUntil({
  332.                                     "labelPlay":1,
  333.                                     "labelStop":_loc8_.totalFrames,
  334.                                     "callback":nextLabel
  335.                                  });
  336.                                  commentGPUntil = _engine.playComment(new CommentObject({"code":_loc9_}));
  337.                               }
  338.                         }
  339.                      }
  340.                   }
  341.                }
  342.             }
  343.          };
  344.          enterFrameListener = function():void
  345.          {
  346.             var _loc1_:String = null;
  347.             if(p.labelPlay !== undefined)
  348.             {
  349.                if(theMovie.currentFrame == framePlay)
  350.                {
  351.                   isOK = true;
  352.                }
  353.             }
  354.             else
  355.             {
  356.                isOK = true;
  357.             }
  358.             if(isOK)
  359.             {
  360.                testeListeMovie();
  361.                _loc1_ = p.labelPlay;
  362.                legendesMediasShow();
  363.                _movie.removeEventListener(Event.FRAME_CONSTRUCTED,enterFrameListener);
  364.                theMovie.functionListener = frameContructedListener;
  365.                if(_levelFunction.hasOwnProperty(["label" + _loc1_]) == true)
  366.                {
  367.                   _levelFunction["label" + _loc1_]();
  368.                }
  369.                _movie.addEventListener(Event.FRAME_CONSTRUCTED,frameContructedListener);
  370.             }
  371.          };
  372.          theMovie.removeListeners = function():void
  373.          {
  374.             this.removeEventListener(Event.FRAME_CONSTRUCTED,enterFrameListener);
  375.             this.removeEventListener(Event.FRAME_CONSTRUCTED,frameContructedListener);
  376.             this.functionListener = undefined;
  377.          };
  378.          if(p.labelPlay == undefined)
  379.          {
  380.             theMovie.functionListener = frameContructedListener;
  381.             theMovie.addEventListener(Event.FRAME_CONSTRUCTED,frameContructedListener);
  382.             theMovie.gotoAndStop(frameStop);
  383.             this.testeListeMovie();
  384.             _timelineManager.addMovie(theMovie);
  385.          }
  386.          else
  387.          {
  388.             theMovie.functionListener = enterFrameListener;
  389.             theMovie.addEventListener(Event.FRAME_CONSTRUCTED,enterFrameListener);
  390.             theMovie.gotoAndPlay(framePlay);
  391.             _timelineManager.removeMovie(theMovie);
  392.          }
  393.       }
  394.       
  395.       private function animFinished() : void
  396.       {
  397.          if(this.isPlayingGPUntil == false)
  398.          {
  399.             return;
  400.          }
  401.          this.animIntern = null;
  402.          if(this.animIntern == null && this.commentGPUntil == null)
  403.          {
  404.             this.nextLabel();
  405.          }
  406.       }
  407.       
  408.       private function commentFinished() : void
  409.       {
  410.          if(this.isPlayingGPUntil == false)
  411.          {
  412.             return;
  413.          }
  414.          if(this.commentGPUntil != null)
  415.          {
  416.             this.commentGPUntil.stop();
  417.             this.commentGPUntil.destroy();
  418.          }
  419.          this.commentGPUntil = null;
  420.          if(this.animIntern == null && this.commentGPUntil == null)
  421.          {
  422.             this.nextLabel();
  423.          }
  424.       }
  425.       
  426.       public function nextLabel() : void
  427.       {
  428.          var _loc2_:int = 0;
  429.          var _loc3_:Timeline = null;
  430.          var _loc4_:MovieClip = null;
  431.          var _loc5_:int = 0;
  432.          var _loc6_:String = null;
  433.          this.clipZapHide();
  434.          if(this.isPlayingGPUntil == false)
  435.          {
  436.             return;
  437.          }
  438.          kilListeners();
  439.          if(this.animIntern != null)
  440.          {
  441.             this.animIntern.destroy();
  442.             this.animIntern = null;
  443.          }
  444.          var _loc1_:int = getPosFrameLabelByName(_movie,_movie.currentLabel);
  445.          if(this.onLabelEnd != null)
  446.          {
  447.             this.onLabelEnd({"label":_movie.currentLabel});
  448.          }
  449.          if(this.GotoAndPlayUntilParams.labelLastCallback != undefined)
  450.          {
  451.             if(this.GotoAndPlayUntilParams.labelLast == undefined)
  452.             {
  453.                this.GotoAndPlayUntilParams.labelLast = this.GotoAndPlayUntilParams.labelStop;
  454.             }
  455.             _loc2_ = this.GotoAndPlayUntilParams.labelLast is String ? int(turnLabelIntoFrame(_movie,this.GotoAndPlayUntilParams.labelLast)) : int(this.GotoAndPlayUntilParams.labelLast);
  456.             if(_loc2_ == _movie.currentFrame)
  457.             {
  458.                this.GotoAndPlayUntilParams.labelLastCallback();
  459.                return;
  460.             }
  461.          }
  462.          this._listeMovieBeforeGTAPU = this.initListeMovie();
  463.          if(_loc1_ < _movie.currentLabels.length - 1)
  464.          {
  465.             _loc4_ = _movie["anim"];
  466.             if(_loc4_ == null)
  467.             {
  468.                _loc4_ = _movie["_anim"];
  469.             }
  470.             if(_loc4_ !== null)
  471.             {
  472.                _loc3_ = new Timeline(_loc4_,_timelineManager);
  473.                _loc3_.Stop();
  474.             }
  475.             _loc5_ = 1;
  476.             while(_loc5_ < 10)
  477.             {
  478.                _loc4_ = _movie["bruit_" + GlobalesFunctions.gimme2digits(_loc5_)];
  479.                if(_loc4_ === null)
  480.                {
  481.                   break;
  482.                }
  483.                _loc3_ = new Timeline(_loc4_,_timelineManager);
  484.                _loc3_.Stop();
  485.                _loc5_++;
  486.             }
  487.             _loc6_ = _movie.currentLabels[_loc1_ + 1].name;
  488.             if(_loc6_.split("_")[0] == "PLAY")
  489.             {
  490.                _movie.timeline.GotoAndPlayUntil({
  491.                   "labelPlay":_loc6_,
  492.                   "labelStop":_movie.currentLabels[_loc1_ + 2].frame - 1,
  493.                   "callback":this.nextLabel
  494.                });
  495.             }
  496.             else if(this.GotoAndPlayUntilParams.labelLastCallback != undefined)
  497.             {
  498.                this.GotoAndPlayUntilParams.labelStop = _loc6_;
  499.                _movie.timeline.GotoAndPlayUntil(this.GotoAndPlayUntilParams);
  500.             }
  501.             else
  502.             {
  503.                _movie.timeline.GotoAndPlayUntil({"labelStop":_loc6_});
  504.             }
  505.          }
  506.          else
  507.          {
  508.             this._levelFunction.endMODULE();
  509.          }
  510.       }
  511.       
  512.       public function initListeMovie() : Vector.<DisplayObject>
  513.       {
  514.          var _loc4_:MovieClip = null;
  515.          var _loc1_:Vector.<DisplayObject> = GlobalesFunctions.getChildrenByTypeRecursive(_movie,MovieClip);
  516.          var _loc2_:int = _loc1_.length;
  517.          var _loc3_:int = 0;
  518.          while(_loc3_ < _loc2_)
  519.          {
  520.             if((_loc1_[_loc3_] as MovieClip).totalFrames > 1 && _loc1_[_loc3_] !== _movie)
  521.             {
  522.                _loc4_ = _loc1_[_loc3_] as MovieClip;
  523.             }
  524.             _loc3_++;
  525.          }
  526.          return _loc1_;
  527.       }
  528.       
  529.       public function testeListeMovie() : void
  530.       {
  531.          var _loc5_:MovieClip = null;
  532.          var _loc1_:Vector.<DisplayObject> = GlobalesFunctions.getChildrenByTypeRecursive(_movie,MovieClip);
  533.          var _loc2_:int = _loc1_.length;
  534.          var _loc3_:int = this._listeMovieBeforeGTAPU.length;
  535.          var _loc4_:int = 0;
  536.          while(_loc4_ < _loc3_)
  537.          {
  538.             if(_loc1_.indexOf(this._listeMovieBeforeGTAPU[_loc4_]) == -1)
  539.             {
  540.                _loc5_ = this._listeMovieBeforeGTAPU[_loc4_] as MovieClip;
  541.                if(_loc5_.totalFrames > 1 && _loc5_ !== _movie)
  542.                {
  543.                   if(_timelineManager.isStoppedMovie(_loc5_) == false)
  544.                   {
  545.                      _loc5_.stop();
  546.                   }
  547.                }
  548.             }
  549.             _loc4_++;
  550.          }
  551.       }
  552.       
  553.       public function initListeMovie_old() : Vector.<DisplayObject>
  554.       {
  555.          var _loc1_:Vector.<DisplayObject> = GlobalesFunctions.getChildrenByTypeRecursive(_movie,MovieClip,false);
  556.          var _loc2_:int = _loc1_.length;
  557.          var _loc3_:int = 0;
  558.          while(_loc3_ < _loc2_)
  559.          {
  560.             if((_loc1_[_loc3_] as MovieClip).totalFrames > 1 && _loc1_[_loc3_] !== _movie)
  561.             {
  562.                (_loc1_[_loc3_] as MovieClip).stop();
  563.             }
  564.             _loc3_++;
  565.          }
  566.          return _loc1_;
  567.       }
  568.       
  569.       public function testeListeMovie_old() : void
  570.       {
  571.          var _loc5_:MovieClip = null;
  572.          var _loc1_:Vector.<DisplayObject> = GlobalesFunctions.getChildrenByTypeRecursive(_movie,MovieClip);
  573.          var _loc2_:int = _loc1_.length;
  574.          var _loc3_:int = this._listeMovieBeforeGTAPU.length;
  575.          var _loc4_:int = 0;
  576.          while(_loc4_ < _loc3_)
  577.          {
  578.             if(_loc1_.indexOf(this._listeMovieBeforeGTAPU[_loc4_]) != -1)
  579.             {
  580.                _loc5_ = _loc1_[_loc1_.indexOf(this._listeMovieBeforeGTAPU[_loc4_])] as MovieClip;
  581.                if(_loc5_.totalFrames > 1 && _loc5_ !== _movie)
  582.                {
  583.                   _loc5_.play();
  584.                }
  585.             }
  586.             _loc4_++;
  587.          }
  588.       }
  589.       
  590.       override public function destroy() : void
  591.       {
  592.          this.Stop();
  593.          this.clipZapHide();
  594.          this.clipZap = null;
  595.          this.labelsCallback = null;
  596.          this._levelFunction = null;
  597.          this._listeMovieBeforeGTAPU.length = 0;
  598.          this.GotoAndPlayUntilParams = null;
  599.          if(this.commentGPUntil != null)
  600.          {
  601.             this.commentGPUntil.destroy();
  602.             this.commentGPUntil.stop();
  603.          }
  604.          this.commentGPUntil = null;
  605.          this.onLabelEnd = null;
  606.          if(this.animIntern != null)
  607.          {
  608.             this.animIntern.destroy();
  609.          }
  610.          this.animIntern = null;
  611.          super.destroy();
  612.       }
  613.    }
  614. }
  615.