Packagefeathers.utils
Classpublic class ScreenDensityScaleFactorManager
InheritanceScreenDensityScaleFactorManager Inheritance Object

Automatically manages the Starling view port and stage dimensions to create an appropriate contentScaleFactor value for the current mobile device using the screen density (sometimes referred to as DPI or PPI). The stage and view port will be resized without letterboxing. Additionally, the view port and stage will be automatically updated if the native stage resizes or changes orientation.

The contentScaleFactor values calculated by this class are based on a combination of the screen density buckets supported by Google Android and the native scale factors used for Apple's iPhone:

NameDensityScale Factor
ldpi1200.75
mdpi1601
hdpi2401.5
xhdpi3202
xxhdpi4803
xxxhdpi6404

The density values in the table above are approximate. The screen density of an iPhone 5 is 326, so it uses the scale factor from the "xhdpi" bucket because 326 is closer to 320 than it is to 480.

Providing textures for every scale factor is optional. Textures from another scale factor can be automatically scaled to fit the current scale factor. For instance, since "ldpi" devices with a low screen density typically aren't manufactured anymore, "mdpi" textures will probably be "good enough" for these legacy devices, if your app encounters one. The larger textures will be automatically scaled down, and the app will look the same as it would if you were using lower resolution textures.

Special behavior has been implemented for iPads to give them scale factors of 1 and 2, just like native apps. Using Android's rules for DPI buckets, non-Retina iPads would have been "ldpi" devices (scale factor 0.75) and Retina iPads would have been "hdpi" devices (scale factor 1.5. However, because it makes more sense to make Starling use the same scale factor as native apps on iPad, this class makes a special exception just for them.

The following example demonstrates how to use ScreenDensityScaleFactorManager:

     this._starling = new Starling( RootClass, this.stage, null, null, Context3DRenderMode.AUTO, Context3DProfile.BASELINE );
     this._scaler = new ScreenDensityScaleFactorManager(this._starling);

When using this class, you should not attempt to manually resize the Starling view port or stage manually. This class manages their dimensions automatically on its own.



Public Methods
 MethodDefined By
  
Constructor.
ScreenDensityScaleFactorManager
Constructor Detail
ScreenDensityScaleFactorManager()Constructor
public function ScreenDensityScaleFactorManager(starling:Starling)

Constructor.

Parameters
starling:Starling