FullScreen mode in AS2
UPDATE: Source files are added and code is now in-post. Here is also a follow up on this article for AS3 and AIR
A client asked if it was possible to go FullScreen in AS2 and i said: “No, only from AS3, FlashPlayer 9″.
However i recently found out that this is possible to do it in AS2 , so below is a little code that will do this.
You do have to keep a couple of things in mind and put this into practice. Below is a little list:
- To enable full-screen mode, add the allowFullScreen parameter in the object and embed tags in the HTML page that contains the reference to the SWF file, with allowFullScreen set to “true“, as shown in the following example:<param name=”allowFullScreen” value=”true” />
…
<embed xsrc=”example.swf” allowFullScreen=”true” … > - The fullScreen setting is not supported for “windowless” (transparent windowless or opaque windowless) playback. If you have wmode set to opaque or transparent in the HTML page hosting the SWF file, the user will not be able to switch Flash Player to full-screen mode.
- Full-screen mode is initiated in response to a mouse click or key press by the user; the movie cannot change Stage.displayState without user input. While Flash Player is in full-screen mode, all keyboard input is disabled (except keyboard shortcuts that take the user out of full-screen mode). A Flash Player dialog box appears over the movie when users enter full-screen mode to inform the users they are in full-screen mode and that they can press the Escape key to end full-screen mode.
Attached is the code and you can check the example HTML here.
And the sourcefiles are for download here
Code used in this example:
var myButton:mx.controls.Button;
Stage.scaleMode = "noScale";
myButton_btn.label = "Toggle Fullscreen";
myButton_btn.setSize(150,22);
var buttonListener:Object = new Object();
buttonListener.click = function(evt:Object) {
Stage.displayState = Stage.displayState == "normal" ? "fullScreen" : "normal";
}
myButton_btn.addEventListener("click", buttonListener);
Please consider to buying me a coffee.






Please upload the file again! I get a 404 when i try to download it. Great tutorial by the way. Thank YOU!!!
Hey do you know if this only works with as2 in flash player 9 or does it also work in flash player 8?
Thanks,
Bentley
Hi Bently,
No this does not work in Flash Player 8 because the displayState propery is not part of the player. I have not found a way to do this in FP8, unfortunately.
Cheers,
Sidney
That’s what I was looking for.
Thanks a lot.
There’s no file for the download, so I’ll try right now.
Ciao.
Ugo
I have FP 8 on my system. Still i am able to go to full screen mode when i press Full Screen button in You tube.
How is it possible, if displayState property is not supported in FP 8?
Or is the Youtube player that matters?
this is great. i have been putting off work on updating my site to learn AS 3 and full screen is one of the reasons i was doing so. i am also getting an error when i try to download the files. would you be able to upload them again. thanks!
The source files please!!
Hi Sasha and others,
Will post the source files after the weekend for you.
Greets Sid
This seems like a good idea but if you’re developing in Flash8 with AS2 then Stage[displayState] is not supported.
I have Flash 8 professional and the flashplayer is version 9. It still doesn’t work.
Thanks for trying.
Please ignore me. I’ve just checked and it works fine. I’d cut and pasted the object code and the quotes are in a different encoding.
Thanks so much!
i would like to the source file.would you mind to share it again? i’m getting 404 file not found error like others.
thanks
Hi.
I create website with fullscreen, but i put this code in boton: on (release) { Stage.displayState = “fullscreen”;}
My question: how i can start the fullscreen wihtout on(release)
I try only in first frame: Stage.displayState = “fullscreen”;
but it still doesn`t work!
thanks
Sid,
I hate to ask, but the file seems to be still missing.
thanks,!
Sorry to bother you. But I am just curious if you have posted the source files yet.
This is the exact code I was looking for. Perfect to learn from.
Gracias….esta bueno lo que estaba buscando….
Hi Crist,
Gracias. Bueno oír que esto es lo que usted buscaba
Sid
Hi tetemik,
Yes you can, but you do have to listen for that event. You can do this by listening for the onResize event, set the paramater for the handling function to equal null and you can then call the function like you nomally would. Like so:
addEventListener(Event.RESIZE, handlerForResize, false, 0, true);
function handlerforResize( e:Event = null)
{
// place specific resizing here.
}
handlerforResize();
Or you can leave the =null off and dispatch the event like so:
dispatchEvent(new Event(Event.RESIZE));
Hope this answers your question,
Sid
If you’re developing in Flash8 with AS2 then Stage[displayState] is supported IF you go to the following link, and make the changes to your Flash 8 Files. I did, and it works PERFECT with AS2. Be sure and read ALL the Comments. Some corrections are make there also. The ‘allowfullscreen’ tag is Required in the HTML file. It will NOT go full screen with just the flash file(.swf)
http://julian.empiregn.com/2007/2/22/How-to-create-true-fullscreen-movies-with-Flash
Thanks a lot from İstanbul, great tip.
Thank You!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! You Rock!
I have a similar question..
is there anyway or any component for fullscreen flvplayback component in as2 ?
thanks.
Thanks a lot exactly what i was looking for…
Thanks… Thanks…. Thanks….
Yes there is, the standard FLVPlayback component in CS3 will do just that.
First of all thank you for your reply.
Yes there is a standart flvplayback component in cs3 but isn’t it for as3? i am asking a full screen video player in as2.
This is awesome. Thanks a million!
great job! it works great
but only one problem. works only if i use that button, i tried to use a self created button and nothing happen, having the same instance name and linkage,
is there something i did wrong?
hmm… nice
Thanks a lot for posting this. After searching for two days for various ways to make this work, this helps a lot! Peace!
I would like to create an other self created button too, but if you see the component inspector, you’ll see the lot of parametes &schema too.
Any good advice?
Can you explain what you want to do?
Cheers Sid
I didn’t realize that I had to use the component button either. I tried my own over and over again and then decided to use the flash component button and it worked. Can this feature work if we create our own button instead of using the component button?
It would be nice that when it opened full screen that the toggle button could disappear and then when the user toggled back the button would reappear. Thank you for posting!
Hi Darryl,
Yes you can use your own buttons too of course, that’s the beauty of code
If you want it to disappear just set it to myButton.visible = false; when ever the ‘fullscreen’ clause is set to true
Below is an example of using you own custom button class (it is pseudo code, so replace it with actual classpaths etc. )
import path.to.my.MyButton;
Stage.scaleMode = “noScale”;
var myButton:MyButton = new MyButton();
myButton.addEventListener(“click”, buttonListener);
myButton.label = “Toggle Fullscreen”;
myButton._width = 150;
myButton._height = 22;
function buttonListener( evt:Object ):Void {
Stage.displayState = Stage.displayState == “normal” ? “fullScreen” : “normal”;
}
I’m not quite sure if it is in CS3 , but there is in AS2.
Gracias! Thanks!!!
Hi ,
I have a question.I am using Flash CS5 with AS2.In the fullscreen mode my mouse control are getting disabled.I am not able to click,
Please help.
Thanks!!!
great blog thank you
OR You could use my method.
In the first frame of your movie enter the script
fscommand(“fullscreen”, “true”);
I did this in Flash Pro 8 under AS2.. Much easier.
In the HTML file I have to use this line (when Flash5 generates my HTML)
attributes.allowFullScreen = “true”;
If you want to publish for flash 8 in as2 use following code example:
import flash.display.Stage;
import flash.display.StageDisplayState;
//FULLSCREEN
btn_fullscreen.onRelease=function(){
Stage.displayState = Stage.displayState == “normal” ? “fullScreen” : “normal”;
}