Official website for Web Designer - defining the internet through beautiful design
FOLLOW US ON:
Author: Steve Jenkins
26th December 2009

Tip: Go fullscreen with Flash

SINCE THE RELEASE of Flash Player 9 we’ve been able to enjoy videos at full screen, leaving the browser behind

Tip: Go fullscreen with Flash
SINCE THE RELEASE of Flash Player 9 we’ve been able to enjoy videos at full screen, leaving the browser behind.

With the latest release of Flash Player 10 there is even more reason to take advantage of this feature. Flash Player 10 now can capture keyboard presses as well as mouse clicks when in Full Screen mode so this is perfect for sending your Flash games into full screen mode for the same fully immersive experience we’ve been able to enjoy with video.
To take advantage of this simply add a button to the stage with an instance name of ‘screen_btn’. It’s probably a good idea to label this button ‘screen toggle’ or something else suitable so the user knows what it does. Then add the code shown into your existing ActionScript. The first two lines just import the relevant classes into Flash for button events and the display. The next line connects the screenHandler function to your ‘screen_btn’ on the stage and tells it to run if the button is clicked. The screenHandler function itself is powered by an ‘if’ statement. All this does is simply check if Flash is currently in Full Screen mode. If it is then it changes the mode to normal, but if not it jumps the screen out of the browser.
The very last step is to go to File>Publish Settings and then click on the HTML tab at the top of the pop-up window. Change the template drop menu to Flash Only – Allow Full Screen, and finally click the Publish button to test. This is a quick and simple way to add full screen to any project. Technique Leave the browser behind with Full Screen mode

CODE:

import flash.display.*;
import flash.events.*;
screen_btn.addEventListener(MouseEvent.CLICK, screenHandler);
function screenHandler(e:MouseEvent):void{
if (stage.displayState== StageDisplayState.FULL_SCREEN){
stage.displayState = StageDisplayState.NORMAL
}else{
stage.displayState = StageDisplayState.FULL_SCREEN;
}
}

Tags: ,
  • Tell a Friend
  • Follow our Twitter to find out about all the latest web development, news, reviews, previews, interviews, features and a whole more.

    What's your opinion?

    Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

    Be nice. Keep it clean. Stay on topic. No spam.

    * Required fields