home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 148 / MOBICLIC148.ISO / mac / DATA / DSS148 / DSS148_00 / DSS148_00.swf / scripts / dss148 / Memo.as < prev   
Text File  |  2012-10-16  |  4KB  |  163 lines

  1. package dss148
  2. {
  3.    import com.milanpresse.engine.Engine;
  4.    import flash.net.SharedObject;
  5.    
  6.    public class Memo
  7.    {
  8.       
  9.       public static var NEW_GAME:String = "NEW_GAME";
  10.       
  11.       public static var ATTENTE:String = "ATTENTE";
  12.        
  13.       
  14.       private var _so:SharedObject;
  15.       
  16.       private var _name:String;
  17.       
  18.       private var _e:Engine;
  19.       
  20.       private var _savePoint:Object;
  21.       
  22.       public var modules:Array;
  23.       
  24.       public function Memo(param1:Engine)
  25.       {
  26.          this.modules = [{
  27.             "no":0,
  28.             "vu":true
  29.          },{
  30.             "no":1,
  31.             "vu":false
  32.          },{
  33.             "no":2,
  34.             "vu":false
  35.          },{
  36.             "no":3,
  37.             "vu":false
  38.          },{
  39.             "no":4,
  40.             "vu":false
  41.          },{
  42.             "no":5,
  43.             "vu":false
  44.          }];
  45.          super();
  46.          this._e = param1;
  47.          this._name = this._e.config.rubriqueName;
  48.          this._so = SharedObject.getLocal(this._name,"/");
  49.          if(this._so.data._savePoint == undefined)
  50.          {
  51.             this._savePoint = {
  52.                "moduleNum":this.module.no,
  53.                "status":NEW_GAME
  54.             };
  55.             this.save();
  56.          }
  57.          else
  58.          {
  59.             this.load();
  60.          }
  61.       }
  62.       
  63.       public function clear() : void
  64.       {
  65.          this._so.clear();
  66.          this.modules = [{
  67.             "no":0,
  68.             "vu":true
  69.          },{
  70.             "no":1,
  71.             "vu":false
  72.          },{
  73.             "no":2,
  74.             "vu":false
  75.          },{
  76.             "no":3,
  77.             "vu":false
  78.          },{
  79.             "no":4,
  80.             "vu":false
  81.          },{
  82.             "no":5,
  83.             "vu":false
  84.          }];
  85.          this._savePoint = {
  86.             "moduleNum":0,
  87.             "status":NEW_GAME
  88.          };
  89.          this.save();
  90.       }
  91.       
  92.       public function save() : void
  93.       {
  94.          this._so.data._savePoint = this._savePoint;
  95.          this._so.data.modules = this.modules;
  96.          this._so.flush();
  97.       }
  98.       
  99.       public function load() : void
  100.       {
  101.          this._savePoint = this._so.data._savePoint;
  102.          this.modules = this._so.data.modules;
  103.       }
  104.       
  105.       public function get allModulesFinished() : Boolean
  106.       {
  107.          var _loc1_:int = 0;
  108.          while(_loc1_ < this.modules.length)
  109.          {
  110.             if(this.modules[_loc1_].vu == false)
  111.             {
  112.                return false;
  113.             }
  114.             _loc1_++;
  115.          }
  116.          return true;
  117.       }
  118.       
  119.       public function get nbModulesFinished() : int
  120.       {
  121.          var _loc1_:int = 0;
  122.          var _loc2_:int = 0;
  123.          while(_loc2_ < this.modules.length)
  124.          {
  125.             if(this.modules[_loc2_].vu == true)
  126.             {
  127.                _loc1_++;
  128.             }
  129.             _loc2_++;
  130.          }
  131.          return _loc1_;
  132.       }
  133.       
  134.       public function get module() : Object
  135.       {
  136.          return this.modules[this._e.config.moduleNum];
  137.       }
  138.       
  139.       public function set savePoint(param1:Object) : void
  140.       {
  141.          param1.moduleNum = param1.moduleNum == undefined ? this.module.no : param1.moduleNum;
  142.          this._savePoint = param1;
  143.       }
  144.       
  145.       public function get savePoint() : Object
  146.       {
  147.          return this._savePoint;
  148.       }
  149.       
  150.       public function toString() : String
  151.       {
  152.          var _loc1_:String = "";
  153.          var _loc2_:int = 0;
  154.          while(_loc2_ < this.modules.length)
  155.          {
  156.             _loc1_ += "\r\n" + _loc2_ + " : " + this.modules[_loc2_].vu;
  157.             _loc2_++;
  158.          }
  159.          return _loc1_;
  160.       }
  161.    }
  162. }
  163.