home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 151 / MOBICLIC151.ISO / mac / DATA / BLA151 / BLA151_02 / BLA151_02.swf / scripts / bla_02 / CapsuleAlgo.as
Text File  |  2013-01-17  |  5KB  |  138 lines

  1. package bla_02
  2. {
  3.    import com.milanpresse.engine.Engine;
  4.    import com.milanpresse.engine.initmovieclip.InteractiveMovie;
  5.    import com.milanpresse.engine.managers.PauseManager;
  6.    import com.milanpresse.engine.managers.TimelineManager;
  7.    import com.milanpresse.engine.medias.MediaSwf;
  8.    import com.milanpresse.engine.timelines.Timeline;
  9.    import com.milanpresse.tools.GlobalesFunctions;
  10.    import flash.display.MovieClip;
  11.    import flash.events.Event;
  12.    
  13.    public class CapsuleAlgo
  14.    {
  15.        
  16.       
  17.       private var menu:MediaSwf;
  18.       
  19.       private var menuTimeline:MovieClip;
  20.       
  21.       private var menuTL:Timeline;
  22.       
  23.       private var mainClip:MediaSwf;
  24.       
  25.       private var mainTimeline:MovieClip;
  26.       
  27.       private var _engine:Engine;
  28.       
  29.       private var labelList:Array;
  30.       
  31.       private var _timeline_:Timeline;
  32.       
  33.       private var _timelineManager:TimelineManager;
  34.       
  35.       private var _pauseManager:PauseManager;
  36.       
  37.       private var firstLabel:String = "_01";
  38.       
  39.       private var gSon:int = 1;
  40.       
  41.       public function CapsuleAlgo(engine:Engine)
  42.       {
  43.          super();
  44.          this._engine = engine;
  45.          this._engine.setSubtitles(this._engine.host.subtitlesOn);
  46.          this._engine.setFrameRate(12);
  47.          this.mainClip = this._engine.showSwf({
  48.             "code":"A_" + this._engine.config.moduleName,
  49.             "parent":this._engine.config.layers["content"]
  50.          });
  51.          this.mainTimeline = this.mainClip.swfContent;
  52.          this._timelineManager = new TimelineManager();
  53.          this._timeline_ = new Timeline(this.mainTimeline,this._timelineManager);
  54.          this._engine.levelCZ = this._engine.config.layers["content"];
  55.          this._timeline_.GotoAndPlay(2);
  56.          this.mainTimeline.addEventListener(Event.FRAME_CONSTRUCTED,this.frameContructedListener);
  57.          var BT_FERMER:InteractiveMovie = new InteractiveMovie(this.mainTimeline.BT_FERMER,this._timelineManager);
  58.          BT_FERMER.mc.onPress = function():void
  59.          {
  60.             endMODULE();
  61.             this.kill();
  62.          };
  63.          BT_FERMER.activeMC();
  64.       }
  65.       
  66.       public function frameContructedListener(evt:Event) : void
  67.       {
  68.          if(this.mainTimeline.currentFrameLabel !== null)
  69.          {
  70.             if(this.mainTimeline.currentFrameLabel.substr(3,3) == "fin")
  71.             {
  72.                this.masqueST();
  73.             }
  74.             else
  75.             {
  76.                this.afficheST();
  77.             }
  78.          }
  79.       }
  80.       
  81.       public function afficheST() : void
  82.       {
  83.          this._engine.config.subtitlesBloc.showByCommentID(this._engine.config.commentName + this.mainTimeline.currentFrameLabel.substr(1,2));
  84.          this.gSon += 1;
  85.       }
  86.       
  87.       public function masqueST() : void
  88.       {
  89.          this._engine.config.subtitlesBloc.hide();
  90.          var pNextLabel:int = this.getNextLabel();
  91.          if(pNextLabel == -1)
  92.          {
  93.             this.mainTimeline.removeEventListener(Event.FRAME_CONSTRUCTED,this.frameContructedListener);
  94.             this._timeline_.GotoAndPlayUntilTheEnd(this.mainTimeline.currentFrame + 1,this.endMODULE);
  95.          }
  96.       }
  97.       
  98.       public function getNextLabel() : int
  99.       {
  100.          var pos:int = this._timeline_.getPosFrameLabelByName(this.mainTimeline,this.mainTimeline.currentLabel);
  101.          if(pos < this.mainTimeline.currentLabels.length - 1)
  102.          {
  103.             return this.mainTimeline.currentLabels[pos + 1].frame;
  104.          }
  105.          return -1;
  106.       }
  107.       
  108.       public function G2D(value:int) : String
  109.       {
  110.          return GlobalesFunctions.gimme2digits(value);
  111.       }
  112.       
  113.       public function endMODULE() : void
  114.       {
  115.          trace("fin du module");
  116.          this._engine.host.changeModule({"numMod":0});
  117.       }
  118.       
  119.       public function sleep() : void
  120.       {
  121.          this._pauseManager = new PauseManager(this._engine,this._timelineManager);
  122.          this._pauseManager.sleepMovie(this.mainTimeline);
  123.       }
  124.       
  125.       public function wake() : void
  126.       {
  127.          this._pauseManager.wakeMovie(this.mainTimeline);
  128.       }
  129.       
  130.       public function destroy() : void
  131.       {
  132.          this.mainTimeline.removeEventListener(Event.FRAME_CONSTRUCTED,this.frameContructedListener);
  133.          this._engine.stopAllSounds();
  134.          this._timeline_.kilListeners();
  135.       }
  136.    }
  137. }
  138.