Newest Articles

Flash Media Player
XML Driven Pie Chart
Base Defender
Hangman Game
8 Ball Pool

Popular Articles

Hangman Game
Base Defender
True Fullscreen Flash Mode
3d Rotating Image Cube
Catapult Game
Create Pong

Random Articles

True Fullscreen Flash Mode
Moving Clouds and Waving Grass
Paddle Ball
3d Rotating Image Cube
Space Shooter Game


Shapes the Game
Link to SwfSpot
Swf Spot

Contact me on Google+

rss feed

True Fullscreen Flash Mode

True Fullscreen Flash Mode
AddThis Social Bookmark Button
Description: Toggle a flash applet between normal size and full-screen
Author: John Bezanis
Added: August 20th 2007
Version: Flash 8

Since the Flash Player 9,0,28,0 update, flash applets can go to true full-screen. There are no fancy javascript hacks needed either. Users can toggle between normal size and fullscreen with a simple click, which can toggle Stage["displayState"] from "normal" to "fullScreen". The param allowFullScreen must be set to true in the applet html.
<param name="allowFullScreen" value="true" />
The first thing to do is create a button and add the following code to it:
  1. on(press){
  2.   toggleFullScreen();
  3. }
The code for the function toggleFullScreen and a resize listener are placed on the main stage.
  1. //Don't scale the movie when the stage size changes
  2. Stage.scaleMode="noScale";
  3. //Align the stage to the top left
  4. Stage.align = "TL";
  5. //Function to toggle between fullscreen and normal size
  6. //the toggle fullscreen button calls this function when pressed
  7. function toggleFullScreen(){
  8.   //if normal size, go to fullscreen, else go to normal size
  9.   if(Stage["displayState"]=="normal"){
  10.     Stage["displayState"]="fullScreen";
  11.   }else{
  12.     Stage["displayState"]="normal";
  13.   }
  14. }
  15. //Create a listener for each time the Stage is resized
  16. var resizeListener:Object = new Object();
  17. //Called each time the stage is resized
  18. resizeListener.onResize = function () {
  19.   //Move the button to the center of the screen
  20.   toggleFullScreenButton._x=Stage.width/2;
  21.   toggleFullScreenButton._y=Stage.height/2;
  22. }
  23. //Add the listener to Stage
  24. Stage.addListener(resizeListener);
Example XHTML used for this applet:
<object data=""
type="application/x-shockwave-flash" width="400" height="200" >
<param name="movie" value="" />
<param name="allowFullScreen" value="true" />

The balls were added in to show that the stage extends to the borders of the screen, even when resized.

Download the source file below:

Download Source File
Comments Currently Disabled