Well guys, I've tried lots of ways to get my game running on fullscreen, it seems to be impossible. Here's what I've tried so far:
CODE 1:
stop();
stage.stageWidth = Capabilities.screenResolutionX;
stage.stageHeight = Capabilities.screenResolutionY;
var arrayStars:Array = [];
for(var i:int = 0; i<260; i++)
{
var star:Star = new Star();
star.x = Math.floor(Math.random() * stage.stageWidth);
star.y = Math.floor(Math.random() * stage.stageHeight);
addChild(star);
arrayStars.push(star);
}
CODE 2:
stop();
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
var sX:Number =stage.stageWidth;
var sY:Number = stage.stageHeight;
var arrayStars:Array = [];
for(var i:int = 0; i<260; i++)
{
var star:Star = new Star();
star.x = Math.flo开发者_StackOverflow社区or(Math.random() * sX);
star.y = Math.floor(Math.random() * sY);
addChild(star);
arrayStars.push(star);
}
CODE 3: Similar to code 2, but instead of using the variables sX and sY I've used directly stage.stageWidth and stage.stageHeight. The main problem is not getting the app to run in fullscreen, it does, but the movie clips, stay all in a area, not covering all the screen. I think that the problem may not have to do with the fullscreen methods, maybe with the random generator?
The stage resize to fullScreen and back must be done on user itteraction, fo example mouseClick:
From documentation: "Full-screen mode is initiated in response to a mouse click or key press by the user; the movie cannot change Stage.displayState without user input."
static public function handleStageDisplayStateChange ( e : MouseEvent ) : void
{
if ( stage.displayState == StageDisplayState.NORMAL )
stage.displayState = StageDisplayState.FULL_SCREEN;
else
stage.displayState = StageDisplayState.NORMAL;
}
Try the scalemode
property of stage
. There's also information here: http://active.tutsplus.com/tutorials/actionscript/quick-tip-stretch-your-swf-with-stage-scalemode/
I think code is runned before stage is actually switched to fullscreen. Try this:
private function OnFullScreenButtonMouseClick( _e:MouseEvent ):void {
stage.addEventListener( Event.RESIZE, OnResize, false, 0, true );
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.displayState = StageDisplayState.FULL_SCREEN;
}
...
function OnResize( event:Event ):void {
var sX:Number =stage.stageWidth;
var sY:Number = stage.stageHeight;
var arrayStars:Array = [];
for(var i:int = 0; i<260; i++)
{
var star:Star = new Star();
star.x = Math.floor(Math.random() * sX);
star.y = Math.floor(Math.random() * sY);
addChild(star);
arrayStars.push(star);
}
}
精彩评论