
Код AS3:
public function Startup()
{
addEventListener(flash.events.Event.ADDED_TO_STAGE, init);
}
private function init(e:flash.events.Event):void
{
removeEventListener(flash.events.Event.ADDED_TO_STAGE, init);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
iOS = Capabilities.manufacturer.indexOf("iOS") != -1;
mouseEnabled = mouseChildren = false;
Starling.handleLostContext = !iOS;
Starling.multitouchEnabled = true;
appScaleFactor = viewPort.width < 1025 ? 1 : 2; // тут на ваш выбор
starling = new Starling(Main, stage, viewPort);
starling.simulateMultitouch = false;
starling.enableErrorChecking = false;
starling.addEventListener(starling.events.Event.ROOT_CREATED,
function onRootCreated():void
{
var app:Main = starling.root as Main ;
app.start(assets);
starling.start();
});
this.stage.addEventListener(flash.events.Event.RESIZE, stageResized, false, int.MAX_VALUE, true);
NativeApplication.nativeApplication.addEventListener(
flash.events.Event.ACTIVATE, function (e:*):void { starling.start(); });
NativeApplication.nativeApplication.addEventListener(
flash.events.Event.DEACTIVATE, function (e:*):void { starling.stop(); });
}
private function stageResized(e:flash.events.Event):void
{
starling.stage.stageWidth = this.stage.stageWidth;
starling.stage.stageHeight = this.stage.stageHeight;
var viewPort:Rectangle = RectangleUtil.fit(
new Rectangle(0, 0, stage.stageWidth, stage.stageHeight),
new Rectangle(0, 0, stage.fullScreenWidth, stage.fullScreenHeight),
ScaleMode.SHOW_ALL);
Starling.current.viewPort = viewPort;
if (!textureLoaded){
var appDir:File = File.applicationDirectory;
assets = new AssetManager();
assets.verbose = Capabilities.isDebugger;
assets.enqueue(
appDir.resolvePath(formatString("assets/textures/{0}x", appScaleFactor)),
appDir.resolvePath(formatString("assets/fonts", appScaleFactor))
);
textureLoaded = true;
}
}