0 Replies Latest reply on Jan 27, 2015 3:46 PM by Johninus

    How to let the Stage will be scaled to fit the screen?

    Johninus Level 1

      Refer the code in Exploring full-screen mode in Flash Player | Adobe Developer Connection


      Error "mc is not defined for: mc.contextMenu = fullscreenCM;


      I changed it to: this.contextMenu = fullscreenCM;  without error but it dosen't work out for full screen issue. Thanks,


      // functions to enter and leave full screen mode;

      function goFullScreen(event:ContextMenuEvent):void


          stage.displayState = StageDisplayState.FULL_SCREEN;



      // An alternate full-screen function that uses hardware scaling to display the upper left corner of the stage in full screen.

      function goScaledFullScreen()


          var screenRectangle:Rectangle = new Rectangle(0,0,stage.stageWidth / 2,stage.stageHeight / 2);

          stage.fullScreenSourceRect = screenRectangle;

          stage.displayState = StageDisplayState.FULL_SCREEN;



      function exitFullScreen(event:ContextMenuEvent):void


          stage.displayState = StageDisplayState.NORMAL;



      // function to enable and disable the context menu items,

      // based on what mode we are in.

      function menuHandler(event:ContextMenuEvent):void


          if (stage.displayState == StageDisplayState.NORMAL)


              event.target.customItems[0].enabled = true;

              event.target.customItems[1].enabled = false;




              event.target.customItems[0].enabled = false;

              event.target.customItems[1].enabled = true;




      // create the context menu, remove the built-in items,

      // and add our custom items


      var fullscreenCM:ContextMenu = new ContextMenu();

      fullscreenCM.addEventListener(ContextMenuEvent.MENU_SELECT, menuHandler);


      var fs:ContextMenuItem = new ContextMenuItem("Go Full Screen");

      fs.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, goFullScreen);

      fullscreenCM.customItems.push( fs );

      var xfs:ContextMenuItem = new ContextMenuItem("Exit Full Screen");

      xfs.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, exitFullScreen);

      fullscreenCM.customItems.push( xfs );



      // finally, attach the context menu to a movieclip

      mc.contextMenu = fullscreenCM;