package {
import flash.display.Sprite;
import flash.geom.Rectangle;
import starling.core.Starling;
import starling.events.*;
import flash.display3D.Context3DRenderMode
import flash.display3D.Context3DProfile
import flash.display.StageScaleMode
import flash.display.StageAlign
import flash.display.Bitmap
import flash.display.BitmapData
import flash.display.StageDisplayState
import flash.system.Capabilities
import flash.events.*;
//[SWF(width="640", height="1136", frameRate="45", backgroundColor="#000000")]
[SWF(frameRate="45", backgroundColor="#000000")]
public class Startup extends Sprite
{
private var _starling:Starling;
private var viewPort:Rectangle = new Rectangle();
private var xuse:int = 0;
private var screenx:int = 0;
private var screeny:int = 0;
private var heightadd:int = 0;
private var resincrease:int = 0;
private var stagew:int = 0;
private var stageh:int = 0;
//load or embed your bitmap//
public function Startup()
{
if (Capabilities.screenResolutionX == 1536) {
//ipad
viewPort.setTo(191, 0, 1154, 2048)
xuse = 2
//} else if (Capabilities.screenResolutionX == 640) {
//||Capabilities.cpuArchitecture!=="ARM" ABOVE
//iphone?
// viewPort.setTo(0, 0, 640, 1136)
} else {
//android/iphone
if (Capabilities.cpuArchitecture!=="ARM") {
screenx = 640
screeny = 1136
} else {
screenx = Capabilities.screenResolutionX
screeny = Capabilities.screenResolutionY
}
xuse = 3
if (screenx/screeny < 640/1136) {
//bars on top and bottom
stagew = screenx
stageh = screeny
viewPort.setTo(0,0, stagew, stageh)
heightadd = (screeny - screenx*1136/640) / 2
resincrease = screenx/1136 * 100
} else {
//bars on left and right
stagew = screeny*640/1136
stageh = screeny
viewPort.setTo((screenx-stagew)/2,0, stagew, stageh)
}
}
Starling.multitouchEnabled = true;
_starling = new Starling(Game, stage, viewPort, null, Context3DRenderMode.AUTO, Context3DProfile.BASELINE_EXTENDED);
_starling.start();
_starling.simulateMultitouch = true
_starling.antiAliasing = 0
//_starling.showStats = true
_starling.skipUnchangedFrames = true
if (xuse == 2) {
//ipad
Starling.current.stage.stageWidth = 1154
Starling.current.stage.stageHeight = 2048
} else if (xuse == 3) {
//android/iphone
Starling.current.stage.stageWidth = stagew
Starling.current.stage.stageHeight = stageh
}
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
Starling.current.stage.addEventListener(ResizeEvent.RESIZE, resetScreenSizeMobile)
//stage.scaleMode = StageScaleMode.NO_SCALE;
//stage.align = StageAlign.TOP_LEFT;
}
private function resetScreenSizeMobile(e:Event):void
{
if (screenx == 1536) {
//ipad
} if (Capabilities.cpuArchitecture !== "ARM") {
} else {
//Android/iphone
screenx = Capabilities.screenResolutionX
screeny = Capabilities.screenResolutionY
if (screenx/screeny < 640/1136) {
stagew = screenx
stageh = screeny
viewPort.setTo(0,0, stagew, stageh)
} else {
//bars on left and right
stagew = screeny*640/1136
stageh = screeny
viewPort.setTo((screenx-stagew)/2,0, stagew, stageh)
}
Starling.current.viewPort = viewPort;
Starling.current.stage.stageWidth = stagew
Starling.current.stage.stageHeight = stageh
}
}
}
}