Newest Articles

Photo Reel
Image Color Tinting using Actionscript
3d Rotating Image Cube
Image Slider with Easing
Catapult Game
Mp3 Player with XML Playlist


Popular Articles

True Fullscreen Flash Mode
FLV Player
Image Slider
Mp3 Player with XML Playlist
Album Slide
Page Flipper


Random Articles

LED Text Scroller
Show the Current Frames Per Second
Krypto Movie Quotes
Music Player
Disappearing Button
XHTML Image Mapper


Links

Foundation-Flash
Tutorial4Me
MickM
TutorialQuest
Tutorialsphere.com - Free Online Tutorials
Photochopz
Newgrounds
TWiT
Link to SwfSpot
Swf Spot



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
Total Views: 32890
Views in the Past 7 Days: 1026


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);
  25.  
Example XHTML used for this applet:
<object data="http://www.bezzmedia.com/swfspot/resources/34-fullscreen.swf"
type="application/x-shockwave-flash" width="400" height="200" >
<param name="movie" value="http://www.bezzmedia.com/swfspot/resources/34-fullscreen.swf" />
<param name="allowFullScreen" value="true" />
</object>

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
Questions and Suggestions
I'm sorry, but it doesn't work for me. What do you have to do with applet html?
September 10th 2007 14:09PM   -   EXE
Hi! Thank you! How do you remove the info. bar in the middle that tells you to hit esc. when switching to fullscreen?
September 15th 2007 00:09AM   -   kathleen
Sorry Kathleen, there is no way to remove it.
September 15th 2007 04:09AM   -   John
I beg your pardon, it doesn't work for me too.I tried even after downloading your swf fife in my web page.Could u help me out,please. Thanking you in advance. saminda
September 23rd 2007 05:09AM   -   saminda
Fullscreen mode only works when viewing from a browser and you use the tag <param name="allowFullScreen" value="true" /> in your code. See the html above.
September 23rd 2007 20:09PM   -   John
Dang everytime it goes fullscreen my movie is in the top corner off centered help! :O
September 27th 2007 19:09PM   -   luis
You could put your content into a container movie clip, and then center that container each time the movie is resized.
September 27th 2007 20:09PM   -   John
I am trying to get my site to start in Full screen mode. As I know that Adobe limits this, I am trying to add a simple entery page so the user clicks on a button that says "Launch HDonlineCinema.com" and then the button should start HDonlineCinema.com the video in full screen mode. I am not a program, but a producer. How can I apply the above code to do that. Please this is urgent. Thank you, John JDowling81@hotmail.com
October 25th 2007 14:10PM   -   John Dowling
I ask a question,is js can control the Fullscreen Flash Mode?could you tell me how to do it?
November 16th 2007 02:11AM   -   sunshine
remember, this works only with transparent mode DISABLED
November 16th 2007 03:11AM   -   Jujo
In Safari (MAC) my buttons doesn't works in fullscreen mode ??? You can click on it.. butt the rollover state doesn't work anymore ? Help me
November 22nd 2007 02:11AM   -   Hekka
What version of flash are you running?
November 22nd 2007 06:11AM   -   John
Hey Jujo... What the heck is transparent mode, and disabled where/how?
November 23rd 2007 19:11PM   -   Bisimo
thanks so much! works perfectly :o)
November 26th 2007 16:11PM   -   jodi
just started with my first website ! and i want to have my flash site in fullsreen can sombody edit this ! and can somebody explain this in a more easy way.
November 29th 2007 14:11PM   -   meloen
I can't seem to get this to work! Downloaded the resource and the .swf works perfect in my HTML editor But When I use the same attibutes *codes* as for this one on my own project, nothing seems to work :| Any help would be appreciated :D
December 2nd 2007 11:12AM   -   Bob
Does anybody know how to get this to work in both IE6 and opera?? It works perfectly in Firefox, Safari, and Netscape for me.. Are there any known hacks or anything, or is this just something that has not been dealt with yet??
December 8th 2007 20:12PM   -   Rick
Rick, It works for me using those browsers. Maybe your browsers are using older versions of flash.
December 9th 2007 01:12AM   -   John
I experienced the same problems as Hekka... I use Firefox/Safari for Mac. In the fullscreen-Mode the Rollovers don't work anymore... Is there some fix for this problem? thank you.
December 19th 2007 12:12PM   -   Jörg
This example does not work because it is written in AS 2.0. If you try to publish the example .fla in Flash 9, AS 3.0, the movie will throw multiple errors.
December 19th 2007 15:12PM   -   dj
The example works for me in Safari 3.0.4 Flash Player 9.0r115. It also worked in Firefox but not in IE 5.2 for the Mac.
December 26th 2007 09:12AM   -   Paul
thanks!
January 12th 2008 18:01PM   -   TREx
Thanks dost!! It really work for me....... :)
January 14th 2008 06:01AM   -   shadab
it wont work here!
January 20th 2008 22:01PM   -   neo
Hi, first of all great little tut! Just a quick question ... Would this fullscreen method work across a 2 monitor setup??? ( the setup in question has 1 monitor at a larger resolution to the other monitor) thanks !!!
January 22nd 2008 16:01PM   -   tomo
This was very good tut. I only have one problem. It doesn't work in Mozilla Firefox. And I followed these steps: ActionScript: I made button and attached script to it, as said in tut. Then I created a function that this script calls. HTML: I just added following line: <param name="allowFullScreen" value="true" /> This works perfectly in IE, but not at all in Mozilla. Any idea why?
January 24th 2008 07:01AM   -   vlada
vlada, it works fine for me in Mozilla. Maybe you need to upgrade your mozilla flash plugin.
January 25th 2008 22:01PM   -   John
For some people here having trouble, remember that if something doesn't work you should update your Flash plugin and clear your browser cache. Your cache may be using an old version of your .swf, even if you've forced a refresh.
January 28th 2008 10:01AM   -   Alex
make sure you change your publish settings to flash only allow full screen
February 2nd 2008 09:02AM   -   kevin
can the width and height of the fullscreen can be adjusted. i mean, i just want some padding of all the sides? would it be possible?
February 5th 2008 22:02PM   -   neo!
Nice tutorial!
February 13th 2008 01:02AM   -   jd
Works perfect thanks a million! Hehe, tried one hundered times with as3 before I noticed this was as2
February 16th 2008 21:02PM   -   henk
This works great, thanks for all the hard work. But is there a way to make the 'toggle full screen' button disappear in full screen mode and reappear in normal screen mode?
February 24th 2008 12:02PM   -   Jim
i love you guy...this help me alot!!!thanks soooo much!!!
February 25th 2008 21:02PM   -   Jin
For the code to work in both IE and FireFox. you must also allowfullscreen ="true" into the embed tag as well. <embed ... allowfullscreen ="true" ... />
March 7th 2008 03:03AM   -   weilin
Thanks for a great help!
March 12th 2008 00:03AM   -   jomel
Hi, i have a movie where 20 frames are there and i want to open full screen after clicking on button and it jmps to frame 20 where loadmovienum is written... Can you please help me out
March 13th 2008 05:03AM   -   Sus
John, fantastic tutorial, it works wonderfully. I second sunshine - any idea if there's a way to do this via javascript? I have the external interface calls working just dandy, passing text back and forth, but when I call the function to full screen it, nothing happens. If I click the button, it full screens fine. I'm guessing its a security issue, although maybe its just something I'm doing wrong?
March 13th 2008 08:03AM   -   Kevin
Well, ignore me. I found my answer, from <a href="http://www.adobe.com/devnet/flashplayer/articles/full_screen_mode.html">Adobe</a> near the bottom: <em>The ActionScript that initiates full-screen mode can be called only in response to a mouse click or keypress. If it is called in other situations, it will be ignored (in ActionScript 2.0) or throw an exception (in ActionScript 3.0).</em> So, back to the drawing board, I guess.
March 13th 2008 08:03AM   -   Kevin
not work good in opera :( in IE and FireFox work good
March 17th 2008 14:03PM   -   gamemonster
I am running a projector file at fullscreen and if I do a getURL or do a print function (and see system print command), it kicks my program OUT of fullScreen mode and into a Flash 9 player at movie size. Any way to prevent this? Thank you.
March 17th 2008 15:03PM   -   expgfx
Hi, is any one is there to help me out.
March 31st 2008 10:03AM   -   Sam
When I press the escape button I return to the normal mode. I need also to associate to the escape button another action, a LoadMovie; can I put two actions on pressing escape button? How?
April 6th 2008 05:04AM   -   emanuele
emanuele, place your loadMovie code within the toggleFullScreen function.
April 6th 2008 13:04PM   -   John
I tried but probably I putted it not in the exact point
April 6th 2008 13:04PM   -   emanuele
Where I have to put the loadMovie? Can you rewrite the function with also the loadMovie("aaa.swf",_root.target); ? or getURL("http://www.google.com/",_blank); ?
April 9th 2008 11:04AM   -   emanuele
Hi all! I pretty much have the same qustion as expgfx. Im have a fullscreen projector file, where i want to open a html page on top of without it closing fullscreen. I know it works if I export from flash 8. Is this possible from a flash cs3 projector? appreciate any help!
April 10th 2008 05:04AM   -   matt
@Kevin Is your Opera updated? it works fine on mine.
April 10th 2008 11:04AM   -   Rinku
Getting flash to go fullscreen is fine using your code. What I want to do is limit the size of the swf loaded to the movie to 1440 x 1000 pixels. I do not seem to be able to do this. Any ideas appreciated.
April 10th 2008 22:04PM   -   Rob
Thank You Very Much :)) It works well
April 13th 2008 16:04PM   -   learner
the html is very important! must use object data="your movie name.swf" and don't use the embedded syntax
April 16th 2008 17:04PM   -   Sean
the fullscreen button works but my flash is in the top corner. what did i do wrong? is there something in the flash file that i need to change?
April 18th 2008 10:04AM   -   kp
kp, Move the objects each time you resize the screen. Place the code within this function - resizeListener.onResize = function () { You can figure out where it should go by using Stage.width and Stage.height to get the new dimemsions.
April 18th 2008 21:04PM   -   John
Flash cs3 > publish settings > html > template > flash only - allow fullscreen
April 22nd 2008 07:04AM   -   olcay
Hello, at first thank you for this beautiful work. I begin a model of site and I have a problem I use a different cursor and the toggle in fullscreen mode show the basic cursor, is it possible not to see the hand displaying? Here is the example in question to be even more clear: http://www.icare-webdesign.com /estelle Please help me :( prends_le_billet@hotmail.com
April 22nd 2008 16:04PM   -   Icare
thanks
April 23rd 2008 00:04AM   -   inz
Anyone know how to get this code to work via the right click menu? I want fullscreen to be fired from the right click drop down. Cheers
April 24th 2008 05:04AM   -   Mark
i am using a custom cursor, too. (custom mouse) when i run the page in opera my mouse disappears, basic mouse stays still without moving. other browsers works fine. can anyone help me with that? note: i use the last versions of both flash and opera.
June 5th 2008 04:06AM   -   aykha
Is it possible to go full screen and still allow text entry?
June 9th 2008 07:06AM   -   Robin
Hi! I find your Flash tips very helpfull, thank you for your work! If you may help me, please explain how to send a user feedback like this one, from a Flash Interface with a form to an e-mail? "MNM"
June 9th 2008 11:06AM   -   MNM
jukuktk
June 17th 2008 06:06AM   -   samy
when I post the example html (above) on my page it works, but when I use the swf file from the downloaded source file - it doesn't work. I have put the <param name="allowFullScreen" value="true" /> but I think the problem is with the swf??? can anyone help?
June 22nd 2008 20:06PM   -   dan
is this version able to do full screen - 9.0.0.498 ? thanks
June 22nd 2008 20:06PM   -   dan
Dan, I'm pretty sure the javascript function is nmot receiving the param allowFullScreen. You are aware that IE has settled with eolas and is no longer using 'click here to activate'?
June 23rd 2008 10:06AM   -   John
Cheers John got it working.. . .legend!
June 24th 2008 22:06PM   -   dan
Add a Question or Suggestion
name:
website (optional):
captcha type the characters into the box
message (5000 characters or less):