Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Full Screen on Flex

    • 0
    • 2
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 781
    Comment on it

    Some time we need to apply the full screen in swf. The following code can be used for full screen.

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx" applicationComplete="init(event)">
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
            <fx:String id="dispState" />
        </fx:Declarations>
    
        <fx:Script>
            <![CDATA[
                import flash.display.StageDisplayState;
    
                import mx.core.FlexGlobals;
                private function init(evt:Event):void {
                    /* Set up full screen handler. */
    
                    FlexGlobals.topLevelApplication.stage.addEventListener(FullScreenEvent.FULL&#95;SCREEN, fullScreenHandler);
                    dispState = FlexGlobals.topLevelApplication.stage.displayState;
                }
    
                private function fullScreenHandler(evt:FullScreenEvent):void {
                    dispState = FlexGlobals.topLevelApplication.stage.displayState + " (fullScreen=" + evt.fullScreen.toString() + ")";
                    if (evt.fullScreen) {
                        /* Do something specific here if we switched to full screen mode. */
                    } else {
                        /* Do something specific here if we switched to normal mode. */
                    }
                }
    
                private function toggleScreen():void {
                    try {
                        switch (FlexGlobals.topLevelApplication.stage.displayState) {
                            case StageDisplayState.FULL&#95;SCREEN:
                                /* If already in full screen mode, switch to normal mode. */
                                FlexGlobals.topLevelApplication.stage.displayState = StageDisplayState.NORMAL;
                                break;
                            default:
                                /* If not in full screen mode, switch to full screen mode. */
                                FlexGlobals.topLevelApplication.stage.displayState = StageDisplayState.FULL&#95;SCREEN;
                                break;
                        }
                    } catch (err:SecurityError) {
                        // ignore
                    }
                }
            ]]>
        </fx:Script>
    
    
        <mx:Label x="10" y="20" text="width={FlexGlobals.topLevelApplication.width}" />
        <mx:Label x="10" y="50" text="height={FlexGlobals.topLevelApplication.height}" />
        <mx:Label text="displayState={dispState}" />
    
        <mx:Button x="10" y="100" label="FullScreen" click="toggleScreen()" />
    </s:Application>
    

    In above code the toggleScreen function will handel the full screen feature.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: