我写了这段代码,为了测试方向的变化,我画了一个宽度=stage.stageHeight,高度=stage.stageHeight的四边形,当改变方向时,四边形的宽度显示为800而不是更多[stage.stageHeight = 1232 , stage.stageWidth = 800] mobileTest.as
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageOrientation;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.StageOrientationEvent;
import starling.core.Starling;
import starling.display.Quad;
public class mobileTest extends Sprite
{
private var myStarling:Starling;
public function mobileTest()
{
super();
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(flash.events.Event.RESIZE,onResize);
}
private function onResize(e:flash.events.Event):void
{
if (myStarling == null)
{
Starling.handleLostContext = true;
myStarling = new Starling(Main,stage);
myStarling.start();
}
}
}
}
Main.as 类
package
{
import feathers.themes.AeonDesktopTheme;
import starling.core.Starling;
import starling.display.Quad;
import starling.display.Sprite;
import starling.events.Event;
public class Main extends Sprite
{
private var theme:AeonDesktopTheme;
public function Main()
{
super();
this.addEventListener(starling.events.Event.ADDED_TO_STAGE,addToStage);
}
private function addToStage(e:starling.events.Event):void
{
this.theme = new AeonDesktopTheme( this.stage );
var quad:Quad = new Quad(stage.stageHeight,stage.stageHeight,0xff0000);
addChild(quad);
}
}
}