Setting the Stage.displayState property to StageDisplayState.FULL_SCREEN tells the Flash Player to expand the stage to fill the user's screen. For security reasons a SWF cannot change the Stage displayState without user input.

While this restriction makes sense in a browser, it can be annoying if you're writing a Flash game and you want it to sart in fullscreen mode right away. However, there's an easy solution to going into fullscreen mode without requiring the user to explicitly allow the operation.

The trick is to use SWF Studio to fake a keystroke using the Keyboard.sendKey function. So your Flash app still waits for user input, but the user never has to send it because SWF Studio takes care of that for you.

In the example below we're sending the key code for a right arrow (ssKey.VK_RIGHT) to our own application Window (ssGlobals.ssHWND), which neatly gets around the requirement for switching into fullscreen mode in response to user input.

ssDefaults.synchronousCommands = true;

if (stage)
   addEventListener(Event.ADDED_TO_STAGE, init);

function init(e:Event):void
   stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
   ssCore.Keyboard.sendKey({hwnd:ssGlobals.ssHWND, key:ssKey.VK_RIGHT});

function onKeyHandler(e:KeyboardEvent):void
   stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
   var r:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
   stage.fullScreenSourceRect = r;
   stage.displayState = StageDisplayState.FULL_SCREEN;

Another annoying limitation of fullscreen mode in Flash is that all keyboard input is disabled. You might think you could use StageDisplayState.FULL_SCREEN_INTERACTIVE, but that only works in the Flash standalone player and Adobe AIR.

In SWF Studio V3.9 we've added a new command to get around this by allowing you to detect keyboard events while the Flash player is running in fullscreen mode.