home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Puzzle / Clusterz / Clusterz.swf / scripts / ENGINE / INTERFACE / OBackground.as < prev    next >
Encoding:
Text File  |  2008-09-12  |  3.3 KB  |  122 lines

  1. package ENGINE.INTERFACE
  2. {
  3.    import ENGINE.CORE.OGlobal;
  4.    import ENGINE.DISPLAY.OBM;
  5.    import ENGINE.DISPLAY.OBitmap;
  6.    import ENGINE.DISPLAY.OSprite;
  7.    import flash.display.Bitmap;
  8.    import flash.display.BitmapData;
  9.    import flash.display.Sprite;
  10.    import flash.geom.Rectangle;
  11.    
  12.    public class OBackground extends OSprite
  13.    {
  14.        
  15.       
  16.       protected var iImages:Array;
  17.       
  18.       protected var iIInd:int = 0;
  19.       
  20.       public function OBackground(param1:Array, param2:int = 0)
  21.       {
  22.          iIInd = 0;
  23.          super();
  24.          this.iImages = param1;
  25.          this.prIInd = param2;
  26.       }
  27.       
  28.       public function Make() : void
  29.       {
  30.          var _loc1_:Sprite = null;
  31.          var _loc2_:BitmapData = null;
  32.          var _loc3_:OBM = null;
  33.          var _loc4_:Rectangle = null;
  34.          var _loc5_:Rectangle = null;
  35.          var _loc6_:int = 0;
  36.          var _loc7_:int = 0;
  37.          var _loc8_:Number = NaN;
  38.          var _loc9_:int = 0;
  39.          var _loc10_:Bitmap = null;
  40.          var _loc11_:int = 0;
  41.          var _loc12_:OBitmap = null;
  42.          if(this.iImages == null)
  43.          {
  44.             return;
  45.          }
  46.          this.Free();
  47.          if(this.iImages[this.iIInd] is Class)
  48.          {
  49.             _loc1_ = new this.iImages[this.iIInd]();
  50.             _loc2_ = new BitmapData(_loc1_.width,_loc1_.height,false,4294967295);
  51.             _loc2_.draw(_loc1_);
  52.          }
  53.          if(this.iImages[this.iIInd] is BitmapData)
  54.          {
  55.             _loc2_ = this.iImages[this.iIInd];
  56.             _loc1_ = new Sprite();
  57.             _loc10_ = new Bitmap(_loc2_);
  58.             _loc1_.addChild(_loc10_);
  59.          }
  60.          _loc3_ = new OBM(_loc2_,0,0,_loc1_.width,_loc1_.height);
  61.          _loc4_ = OGlobal.ViewporRect;
  62.          _loc5_ = OGlobal.StageRect;
  63.          this.x = -_loc4_.x;
  64.          this.y = -_loc4_.y;
  65.          if((_loc6_ = Math.floor(_loc5_.width / _loc1_.width)) == 0)
  66.          {
  67.             return;
  68.          }
  69.          if((_loc7_ = Math.floor(_loc5_.height / _loc1_.height)) == 0)
  70.          {
  71.             return;
  72.          }
  73.          if(_loc5_.width - _loc6_ * _loc1_.width > 0)
  74.          {
  75.             _loc6_++;
  76.          }
  77.          if(_loc5_.height - _loc7_ * _loc1_.height > 0)
  78.          {
  79.             _loc7_++;
  80.          }
  81.          _loc8_ = OGlobal.Scale;
  82.          _loc9_ = 0;
  83.          while(_loc9_ < _loc7_)
  84.          {
  85.             _loc11_ = 0;
  86.             while(_loc11_ < _loc6_)
  87.             {
  88.                _loc12_ = new OBitmap(_loc3_,_loc11_ * _loc1_.width / _loc8_,_loc9_ * _loc1_.height / _loc8_);
  89.                this.addChild(_loc12_);
  90.                _loc11_++;
  91.             }
  92.             _loc9_++;
  93.          }
  94.       }
  95.       
  96.       override public function Free() : void
  97.       {
  98.          super.Free();
  99.       }
  100.       
  101.       public function set prIInd(param1:int) : void
  102.       {
  103.          this.iIInd = param1;
  104.          if(this.iImages == null)
  105.          {
  106.             this.iIInd = -1;
  107.             return;
  108.          }
  109.          if(this.iIInd >= this.iImages.length - 1)
  110.          {
  111.             this.iIInd = this.iImages.length - 1;
  112.          }
  113.          Make();
  114.       }
  115.       
  116.       public function get prIInd() : int
  117.       {
  118.          return this.iIInd;
  119.       }
  120.    }
  121. }
  122.