Newest Articles

XML Driven Pie Chart
Base Defender
Hangman Game
8 Ball Pool
Photo Reel
Image Color Tinting using Actionscript


Popular Articles

True Fullscreen Flash Mode
Mp3 Player with XML Playlist
Base Defender
FLV Player
Hangman Game
Image Slider


Random Articles

Hangman Game
Horizontal Line Transition
Photo Reel
Mouse Following Preloader
Paddle Ball
Custom Mouse Cursor


Links

Foundation-Flash
MickM
TutorialQuest
Tutorialsphere.com - Free Online Tutorials
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: 59603
Views in the Past 7 Days: 859


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
Comments
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
the script works well wid as 2, but wt to do with as3??, pl help
July 15th 2008 01:07AM   -   bharathi
It's really superb... Good Job...
August 1st 2008 04:08AM   -   Dhiren
Does anyone know how to set flash .exe file fullscreen on vista OS ?
August 1st 2008 08:08AM   -   Piter
Hi, I added a movieclip inside the main movie to keep my clip centered, however the toggle button switches position when I go fullscreen & then centers on top of my movie when I return...? How can I keep the toggle button at one specific point in the movie ? THANKS !
August 15th 2008 14:08PM   -   Jonny
congrats for the tutorial :))
August 15th 2008 16:08PM   -   Leo
I had no problems with the code, but when I click the button my .swf doesn't resize. Instead it goes to the top left corner. Any ideas?
August 22nd 2008 00:08AM   -   Jounior
excellent work
August 26th 2008 01:08AM   -   vijay
i changed the button position but it doesnt work. for eg: i positioned the button bottom of the stage, but when i pressed the button, that time the button is position center of the stage. But i want same position in fullscreen mode. how is it possible..... if possible please mention the sample of site
August 26th 2008 01:08AM   -   SalemVJN
HI I AM MANGESH. YOUR GIVEN SCRIPT WORKS VERY FINE. THANK YOU VERY MUCH. THANKS A LOT.
August 27th 2008 02:08AM   -   Mangesh
I also want to know why when I change to fullscreen, the text entry is not allowed. What is the problem? How can I solve ???
August 31st 2008 11:08AM   -   gigi
hi, excellent script works in IE & Firefox in Windows but cant make it work in Firefox and Safari in MAC. Can anyone help? tyvm
September 1st 2008 12:09PM   -   Arj
Hi guys, what should i do to let it work using actionscript 3.0?
September 17th 2008 02:09AM   -   Christelle
Hi guys, what should i fix so this could work in actionscript 3.0? thank you
September 17th 2008 02:09AM   -   Christelle
Hi! Thanks! Super tutorial!
September 17th 2008 05:09AM   -   Kacsa
Hello John, nice tutorial..anyway i am facing a little troubles regarding the browser set up. As i exec the index file the setup of the showed content is aligned to the left upper corner "TL" as i press the toggle full screen everything goes fine. after going back from full screen everything is fine...i have just the problem with the first show. Please could you help me with this? Thank you R Tomas
September 19th 2008 17:09PM   -   Tomas
Tomas... I just commented out the alignment and adjusted it in the html publish preferences. Works fine for me. Thanks for the tutorial!
October 15th 2008 10:10AM   -   Fougie
For all the people who can't get this to work in Firefox, add allowFullScreen="true" somewhere inside the embed tag. Firefox doesn't seem to accept parameters declared outside of this tag. My object tag reads as follows: <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="400" height="200" id="34-fullscreen" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="allowFullScreen" value="true" /> <param name="movie" value="34-fullscreen.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#cccccc" /><embed src="34-fullscreen.swf" quality="high" bgcolor="#cccccc" width="400" height="200" name="34-fullscreen" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object> Obviously, not all of this junk is necessary, but it does work :)
October 21st 2008 11:10AM   -   Scott
Hi, Thx for this cool piece of code. Just a remark: sometimes you need to change the allowFullScreen variable at TWO locations. The first is in the object tag, as mentioned before, the second is in the javascript tag: <script language="javascript"> if (AC_FL_RunContent == 0) {alert("This page requires AC_RunActiveContent.js."); } else {AC_FL_RunContent( (...) 'allowFullScreen', 'true', (...)} </script>
October 25th 2008 16:10PM   -   Minh-Duc
thank you very much it's working. thanks a lot
November 5th 2008 00:11AM   -   mangesh
it does work on html file but my flash file not set full screen. whats the problem.
November 25th 2008 06:11AM   -   Ripon
wooow i was looking exactly this !!! thanks a lot!! cheers!!
November 26th 2008 02:11AM   -   migueee
sao tui thay no ko hieu qua gi het. chan, ai la nguoi Viet thi xin comment
November 28th 2008 02:11AM   -   smalltalk
is it possible to toggle full screen just a swf embedded in another swf? i have several movie.swf's embedded in my website.swf and i wanted just the movie.swf's to full screen.
November 29th 2008 12:11PM   -   antoniomg
I have a SERiOUS PROBLEM...please tell me....ive looked everywhere.....i have adobe flash player...and i simply want to watch a flash movie in fullscreen instead of a tiny box...NO I DONT WANT TO REPROGRAM THE WAY EVERYTHING AND WHATEVER NOT WORKS....is it impossible to just tell this player i want it to fit my screen? or am i RETARDED?
December 2nd 2008 23:12PM   -   RageMachine
Really dumb question I'm sure - where is "stage" defined? What is it?
December 3rd 2008 13:12PM   -   dj
I'm trying to have html links that can resize a movie bewteen 2 set sizes and fullscreen, with javascript - can it be done?
December 3rd 2008 13:12PM   -   dj
Let me RE ASK that question a day later...I am a mere user who wishes to activate fullscreen mode while watching a certain flash video. I am not a programmer. I dont understand why this flash video has no fking button to allow fullscreen and others do but why is that???...is there some freakin hack that you guys can link me to force fullscreen?
December 3rd 2008 18:12PM   -   RageMachine
RageMachine, it would be possible if you used your own flash player with a fullscreen button or created a flash file that reads in flash files and can resize them to full screen, neither of which are really simple hacks, since you'd probably want to replace the html as well.
December 3rd 2008 19:12PM   -   John
hi, great tutorial! i wanted to know if i could add this allow fullscreen coding into this format: <script language="javascript" type="text/javascript"> var fl = new Flash("main.swf", "main", "100%", "100%", "8", "#000000", ""); fl.render(); </script> Thanks!
December 14th 2008 08:12AM   -   adrien
The tutorial is great, simple and efficient. But my problem is this: i have a main mc in which I load an external swf.. that is the one for which i'd like to toggle fullscreen. ONLY for this one, the main movie remains unchanged. But when i hit the button it just fullscreens the whole movie. Any suggestions?
December 15th 2008 09:12AM   -   florin187
Below code should work if using swf object to embed <script type="text/javascript" src="swfobject.js"></script> <div id="flashcontent"> <a href="http://adobe.com/go/getFlashPlayer">Click to download flash player </a></div> <script type="text/javascript"> var so = new SWFObject ("main.swf", "sotester", "760", "540", "8", "#000000"); so.addParam("fullscreen", "true"); so.addParam("scale", "noscale"); so.addParam('salign', 'lt'); so.write("flashcontent"); </script>
December 22nd 2008 15:12PM   -   webfaCe
Great article !
December 29th 2008 02:12AM   -   kaan
Is it possible to go full screen and still allow text entry?
January 5th 2009 04:01AM   -   kiruba
Add a Comment
name:
website (optional):
captcha type the characters into the box
message (5000 characters or less):