开发者

Centering AIR application with fullscreen

开发者 https://www.devze.com 2023-01-26 00:17 出处:网络
I have a application developed in AIR /AS 3.0.. i want to run the application in full screen with all the content centered in the window.

I have a application developed in AIR /AS 3.0..

i want to run the application in full screen with all the content centered in the window. i tried to do fullscreen with

stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE  

but turned out all my components dont get centered on the screen as needed(when in full screen) and they get cutoff or they are off screen. Basically the application was developed in lower resolution about 1024x768...but now it needs to run full screen.Also the application loads various modules at runtime they also dont appear to be centered in fullscreen.When the application comes out of fullscreen it also shows scrollbars for the application window..

Edit :Code added :

<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2开发者_如何学编程006/mxml"
          layout="absolute" width="1024" height="768">

     <Application:ApplicationStartContainer id="aps" width="100%" height="100%">

               <mx:ModuleLoader id="moduleLoader"/>    

     </Application:ApplicationStartContainer>            

</mx:WindowedApplication>

On start, the Application goes fullscreen,and the module loader loads modules/swfs

that are of size 1024*768 ,but currently all loaded modules get aligned to x=0 and y=0.

Any ideas?

Thanks all.


layout all of your display objects in a display object container - as children of a new sprite, and listen for a full screen event to center the display object container.

stage.addEventListener(FullScreenEvent.FULL_SCREEN, fullScreenEventHandler);

//assuming the registration point of 'container' is top-left
function fullScreenEventHandler(evt:FullScreenEvent):void
     {
     container.x = stage.stageWidth / 2 - container.width / 2;
     container.y = stage.stageHeight / 2 - container.height / 2;
     }

note that the full screen event is dispatched when both entering and leaving full screen mode.

0

精彩评论

暂无评论...
验证码 换一张
取 消