Actionscript 3 组件的方向不工作
我写了这段代码,为了测试方向的变化,我画了一个宽度=stage.stageHeight,高度=stage.stageHeight的四边形,当改变方向时,显示的四边形的宽度是800而不是更多[stage.stageHeight=1232,stage.stageWidth=800] 移动测试Actionscript 3 组件的方向不工作,actionscript-3,orientation,starling-framework,Actionscript 3,Orientation,Starling Framework,我写了这段代码,为了测试方向的变化,我画了一个宽度=stage.stageHeight,高度=stage.stageHeight的四边形,当改变方向时,显示的四边形的宽度是800而不是更多[stage.stageHeight=1232,stage.stageWidth=800] 移动测试 package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageOrienta
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);
}
}
}
回答:在change orientation eventListner函数中编写以下代码:
var viewPort:Rectangle = new Rectangle(0, 0, stage.fullScreenWidth,stage.fullScreenHeight);
Starling.current.viewPort = viewPort;
Hi这是使用starling的启动文件的代码。检查并更换丢失的WTU。
包裹
{
导入flash.display.Sprite;
导入flash.display.StageAlign;
导入flash.display.StageScaleMode;
导入flash.events.Event;
导入flash.geom.Rectangle;
导入flash.system.Capabilities;
导入starling.core.starling;
导入starling.events.TouchPhase;
//[SWF(width=“2048”,height=“1536”,frameRate=“60”,backgroundColor=“0x000000”)///ipad第四代视网膜
//[SWF(width=“1136”,height=“640”,frameRate=“60”,backgroundColor=“0x000000”)]//第五代iphone
//[SWF(width=“1024”,height=“768”,frameRate=“60”,backgroundColor=“0x000000”)]//ipad
//[SWF(width=“960”,height=“640”,frameRate=“60”,backgroundColor=“0x000000”)]//第四代iphone
[SWF(width=“480”,height=“320”,frameRate=“60”,backgroundColor=“0x000000”)]//iphone第三代
公共级超级宝贝扩展雪碧
{
私人鸟类:椋鸟;
公共功能超级婴儿()
{
//设置常规属性
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP\u左;
Starling.multitouchEnabled=false;//在移动设备上有用
Starling.handleLostContext=false;//在iOS上不需要。节省大量内存!
//为屏幕大小创建合适的视口
变量屏幕宽度:int=stage.stageWidth;
变量屏幕高度:int=stage.stageHeight;
var视口:矩形=新矩形(0,0,屏幕宽度,屏幕高度);
var scaleFactor:uint;
如果(屏幕高度<480){
scaleFactor=1;
}如果(屏幕高度>=480){/&&screenWidth
Hi this is the code for StartUp file using starling. go through it and replace wtever u are missing.
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Rectangle;
import flash.system.Capabilities;
import starling.core.Starling;
import starling.events.TouchPhase;
//[SWF(width="2048", height="1536", frameRate="60", backgroundColor="0x000000")]//ipad 4th generation Retina
//[SWF(width="1136", height="640", frameRate="60", backgroundColor="0x000000")]//iphone 5th generation
//[SWF(width="1024", height="768", frameRate="60", backgroundColor="0x000000")]//ipad
//[SWF(width="960", height="640", frameRate="60", backgroundColor="0x000000")]//iphone 4th generation
[SWF(width="480", height="320", frameRate="60", backgroundColor="0x000000")] //iphone 3rd generation
public class SuperBaby extends Sprite
{
private var mStarling:Starling;
public function SuperBaby()
{
// set general properties
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
Starling.multitouchEnabled = false; // useful on mobile devices
Starling.handleLostContext = false; // not necessary on iOS. Saves a lot of memory!
// create a suitable viewport for the screen size
var screenWidth:int = stage.stageWidth;
var screenHeight:int = stage.stageHeight;
var viewPort:Rectangle = new Rectangle(0, 0, screenWidth, screenHeight);
var scaleFactor:uint;
if(screenHeight < 480){
scaleFactor = 1;
}else if(screenHeight>=480){ //&& screenWidth<=640
scaleFactor = 2;
}
// While Stage3D is initializing, the screen will be blank. To avoid any flickering,
// we display a startup image now and remove it below, when Starling is ready to go.
// launch Starling
mStarling = new Starling(Mainmenu, stage, viewPort);
mStarling.simulateMultitouch = false;
mStarling.enableErrorChecking = false;
Mainmenu.GAME_W=mStarling.stage.stageWidth = uint(screenWidth/scaleFactor);
Mainmenu.GAME_H=mStarling.stage.stageHeight = uint(screenHeight/scaleFactor);
mStarling.stage3D.addEventListener(Event.CONTEXT3D_CREATE, function(e:Event):void
{
mStarling.start();
});
// When the game becomes inactive, we pause Starling; otherwise, the enter frame event
// would report a very long 'passedTime' when the app is reactivated.
}
}
}