Packagestarlingbuilder.engine.util
Classpublic class StageUtil
InheritanceStageUtil Inheritance Object

Helper class to support multiple resolution

Example usage:

         var stageUtil:StageUtil = new StageUtil(stage);
         var size:Point = stageUtil.getScaledStageSize();
         var starling:Starling = new Starling(Game, stage, new Rectangle(0, 0, stageUtil.stageWidth, stageUtil.stageHeight));
         starling.stage.stageWidth = size.x;
         starling.stage.stageHeight = size.y;

See also

Multiple resolution support
Starling Builder demo project


Public Properties
 PropertyDefined By
  stageHeight : int
[read-only] Return stage height of the device
StageUtil
  stageWidth : int
[read-only] Return stage width of the device
StageUtil
Public Methods
 MethodDefined By
  
StageUtil(stage:Stage, designStageWidth:int = 640, designStageHeight:int = 960)
Constructor
StageUtil
  
fitBackground(object:DisplayObject):void
[static] Fit background to the center of the Starling stage.
StageUtil
  
fitNativeBackground(object:DisplayObject, stage:Stage):void
[static] Fit background to the center of the native stage, If the aspect ratio is different, some cropping may happen.
StageUtil
  
getScaledStageSize(stageWidth:int = 0, stageHeight:int = 0):Point
Calculate the scaled starling stage size
StageUtil
Property Detail
stageHeightproperty
stageHeight:int  [read-only]

Return stage height of the device


Implementation
    public function get stageHeight():int
stageWidthproperty 
stageWidth:int  [read-only]

Return stage width of the device


Implementation
    public function get stageWidth():int
Constructor Detail
StageUtil()Constructor
public function StageUtil(stage:Stage, designStageWidth:int = 640, designStageHeight:int = 960)

Constructor

Parameters
stage:Stage — flash stage
 
designStageWidth:int (default = 640) — design stage width of the project
 
designStageHeight:int (default = 960) — design stage height of the project
Method Detail
fitBackground()method
public static function fitBackground(object:DisplayObject):void

Fit background to the center of the Starling stage. If the aspect ratio is different, some cropping may happen.

Parameters

object:DisplayObject — background display object

fitNativeBackground()method 
public static function fitNativeBackground(object:DisplayObject, stage:Stage):void

Fit background to the center of the native stage, If the aspect ratio is different, some cropping may happen.

Parameters

object:DisplayObject — background display object
 
stage:Stage — native stage

getScaledStageSize()method 
public function getScaledStageSize(stageWidth:int = 0, stageHeight:int = 0):Point

Calculate the scaled starling stage size

Parameters

stageWidth:int (default = 0) — stageWidth of flash stage, if not specified then use this.stageWidth
 
stageHeight:int (default = 0) — stageHeight of flash stage, if not specified then use this.stageHeight

Returns
Point — the scaled starling stage