Toggle between Full Screen and normal Screen in Adobe AIR or FLEX.

By | February 27, 2011

Hi all………

We often need to toggle between fullscreen and normal screen in our application.
The following code snippet helps you to toggle between these two screens in Adobe AIR or Flex.
Here I am using StageDisplayState class to do both which has “stage.displayState = StageDisplayState.FULL_SCREEN” and ” stage.displayState = StageDisplayState.NORMAL” constants to do this.

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"  applicationComplete="toggleScreen()">
       <mx:Script>
               <![CDATA[
                       import flash.display.StageDisplayState;
                       private function toggleScreen():void{
                               if(fullScreen.selected == true){
                                       this.goFullScreen();
                               } else {
                                       this.exitFullScreen();
                               }
                       }
                       private function goFullScreen():void {
                               stage.displayState = StageDisplayState.FULL_SCREEN;
                       }
                       private function exitFullScreen():void {
                               stage.displayState = StageDisplayState.NORMAL;
                       }
               ]]>
       </mx:Script>
       <mx:CheckBox label="Full Screen" id="fullScreen" click="this.toggleScreen()"
               	               selected="true"  horizontalCenter="0" verticalCenter="0"/>
</mx:WindowedApplication>
 

Leave a Reply

Your email address will not be published. Required fields are marked *