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

  1. package ENGINE.CORE
  2. {
  3.    import flash.display.Sprite;
  4.    import flash.display.Stage;
  5.    import flash.geom.Rectangle;
  6.    import flash.net.LocalConnection;
  7.    
  8.    public class OGlobal
  9.    {
  10.       
  11.       private static var iFPS:int = 60;
  12.       
  13.       private static var iDomain:String;
  14.       
  15.       private static var iSRect:Rectangle = new Rectangle();
  16.       
  17.       private static var iVRect:Rectangle = new Rectangle(0,0,800,600);
  18.       
  19.       private static var iStage:Stage;
  20.       
  21.       private static var iScale:Number = 1;
  22.       
  23.       private static var iAppName:String;
  24.       
  25.       private static var iOldScale:Number = 1;
  26.        
  27.       
  28.       public function OGlobal()
  29.       {
  30.          super();
  31.       }
  32.       
  33.       public static function get FPS() : int
  34.       {
  35.          return OGlobal.iFPS;
  36.       }
  37.       
  38.       public static function CheckDomain(param1:String) : Boolean
  39.       {
  40.          var _loc2_:int = 0;
  41.          _loc2_ = OGlobal.iDomain.indexOf(param1);
  42.          return _loc2_ >= 0 && _loc2_ <= 4;
  43.       }
  44.       
  45.       public static function ToLocal(param1:Number) : Number
  46.       {
  47.          return param1 / OGlobal.iScale;
  48.       }
  49.       
  50.       public static function set FPS(param1:int) : void
  51.       {
  52.          OGlobal.iFPS = param1;
  53.          if(OGlobal.iStage)
  54.          {
  55.             OGlobal.iStage.frameRate = param1;
  56.          }
  57.       }
  58.       
  59.       public static function Rescale(param1:Sprite, param2:Boolean = true) : void
  60.       {
  61.          var _loc3_:Number = NaN;
  62.          _loc3_ = OGlobal.iStage.stageWidth / OGlobal.iStage.stageHeight <= 800 / 600 ? OGlobal.iStage.stageWidth / 800 : OGlobal.iStage.stageHeight / 600;
  63.          OGlobal.iSRect.x = 0;
  64.          OGlobal.iSRect.y = 0;
  65.          OGlobal.iSRect.width = OGlobal.iStage.stageWidth;
  66.          OGlobal.iSRect.height = OGlobal.iStage.stageHeight;
  67.          OGlobal.iVRect.width = Math.round(800 * _loc3_);
  68.          OGlobal.iVRect.height = Math.round(600 * _loc3_);
  69.          OGlobal.iVRect.x = Math.floor((OGlobal.iStage.stageWidth - OGlobal.iVRect.width) / 2);
  70.          OGlobal.iVRect.y = Math.floor((OGlobal.iStage.stageHeight - OGlobal.iVRect.height) / 2);
  71.          if(param2)
  72.          {
  73.             param1.x = OGlobal.iVRect.x;
  74.             param1.y = OGlobal.iVRect.y;
  75.          }
  76.          OGlobal.iScale = _loc3_;
  77.       }
  78.       
  79.       public static function get prStage() : Stage
  80.       {
  81.          return OGlobal.iStage;
  82.       }
  83.       
  84.       public static function ClearScale() : void
  85.       {
  86.          OGlobal.iOldScale = OGlobal.iScale;
  87.          OGlobal.iScale = 1;
  88.          OGlobal.iVRect = OGlobal.iSRect.clone();
  89.       }
  90.       
  91.       public static function ToGlobal(param1:Number) : Number
  92.       {
  93.          return param1 * OGlobal.iScale;
  94.       }
  95.       
  96.       public static function set AppName(param1:String) : void
  97.       {
  98.          OGlobal.iAppName = "WellGames_" + param1;
  99.       }
  100.       
  101.       public static function get Domain() : String
  102.       {
  103.          return OGlobal.iDomain;
  104.       }
  105.       
  106.       public static function SetDomain() : void
  107.       {
  108.          var _loc1_:LocalConnection = null;
  109.          _loc1_ = new LocalConnection();
  110.          OGlobal.iDomain = _loc1_.domain;
  111.       }
  112.       
  113.       public static function get StageRect() : Rectangle
  114.       {
  115.          return OGlobal.iSRect;
  116.       }
  117.       
  118.       public static function ScaleFloor(param1:Number) : Number
  119.       {
  120.          return Math.floor(param1 * OGlobal.iScale) / OGlobal.iScale;
  121.       }
  122.       
  123.       public static function get Scale() : Number
  124.       {
  125.          return OGlobal.iScale;
  126.       }
  127.       
  128.       public static function get ViewporRect() : Rectangle
  129.       {
  130.          return OGlobal.iVRect;
  131.       }
  132.       
  133.       public static function get AppName() : String
  134.       {
  135.          return OGlobal.iAppName;
  136.       }
  137.       
  138.       public static function set prStage(param1:Stage) : void
  139.       {
  140.          OGlobal.iStage = param1;
  141.       }
  142.       
  143.       public static function RestoreScale() : void
  144.       {
  145.          OGlobal.iScale = OGlobal.iOldScale;
  146.       }
  147.       
  148.       public static function ScaleMod(param1:Number) : Number
  149.       {
  150.          var _loc2_:Number = NaN;
  151.          _loc2_ = param1 * OGlobal.iScale;
  152.          return (_loc2_ - Math.floor(_loc2_)) / OGlobal.iScale;
  153.       }
  154.    }
  155. }
  156.