home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2012 April / ME_04_2012.iso / Video-Tutorial / iPhoto / media / player.swf / scripts / mx / utils / DensityUtil.as < prev    next >
Encoding:
Text File  |  2011-11-11  |  1.2 KB  |  43 lines

  1. package mx.utils
  2. {
  3.    import mx.core.DPIClassification;
  4.    import mx.core.RuntimeDPIProvider;
  5.    import mx.core.Singleton;
  6.    
  7.    public class DensityUtil
  8.    {
  9.       private static var runtimeDPI:Number;
  10.       
  11.       public function DensityUtil()
  12.       {
  13.          super();
  14.       }
  15.       
  16.       public static function getRuntimeDPI() : Number
  17.       {
  18.          if(!isNaN(runtimeDPI))
  19.          {
  20.             return runtimeDPI;
  21.          }
  22.          var _loc1_:Class = Singleton.getClass("mx.core::RuntimeDPIProvider");
  23.          if(!_loc1_)
  24.          {
  25.             _loc1_ = RuntimeDPIProvider;
  26.          }
  27.          var _loc2_:RuntimeDPIProvider = RuntimeDPIProvider(new _loc1_());
  28.          runtimeDPI = _loc2_.runtimeDPI;
  29.          return runtimeDPI;
  30.       }
  31.       
  32.       public static function getDPIScale(param1:Number, param2:Number) : Number
  33.       {
  34.          if(param1 != DPIClassification.DPI_160 && param1 != DPIClassification.DPI_240 && param1 != DPIClassification.DPI_320 || param2 != DPIClassification.DPI_160 && param2 != DPIClassification.DPI_240 && param2 != DPIClassification.DPI_320)
  35.          {
  36.             return NaN;
  37.          }
  38.          return param2 / param1;
  39.       }
  40.    }
  41. }
  42.  
  43.