Fullscreen in Flash/AS and HTML5/JS

Monkey Programming Forums/User Modules/Fullscreen in Flash/AS and HTML5/JS

thoast(Posted 2013) [#1]
With this small module the user can go fullscreen in flash and html5 apps.

Flash and HTML5 require a previous click/button event, so i bound the call with a canvas/stage click event.

Example of usage like a button:

If (MouseX() > 50 And MouseX() < 150 And MouseY() > 50 And MouseY() < 150)
Fullscreen.eventOn()
Else
Fullscreen.eventOff()
End


Whenever the user clicks and fullscreen event is on, fullscreen will appear.

Go for your questions and suggestions.

Download:
http://testarea.deutschehandarbeit.de/monkey/fullscreen.zip


ziggy(Posted 2013) [#2]
That's nice!


Supertino(Posted 2013) [#3]
Very nice thankyou


Alex(Posted 2014) [#4]
Can I go fullscreen on start?
How do I do that?
Thanks! And sorry for dumb question.


Paul - Taiphoz(Posted 2014) [#5]
I think it might need a mouse click..

All you need to do is setup a button on your menu for full screen and call ON when its pressed, and then when the mouse is no longer over the button call OFF so no further mouse clicks trigger the event.

Might be nice thoast if you added a small delay once its triggered so that you cant spam the screen change with rapid mouse clicks..

Nice work well handy.


Paul - Taiphoz(Posted 2014) [#6]
OH, also while in full screen mode the KeyBoard Input seems to be disabled so I could not control my player, mouse works fine I think arrows did as well but nothing from the querty side does.


Paul - Taiphoz(Posted 2014) [#7]
I patched that Fullscreen issue myself, the amended code can be found bellow.

There may be some compatibility issues with other browsers like safari so this could use some testing, works on Chrome which is all I use, there are workarounds to enable keyboard input for the other browsers but the call is a little different so you would need to do a quick browser check and then do the appropriate call to enable keyboards...

Hope it helps.

format_code('
Fullscreen.toggle = function() {
if(Fullscreen.active()) {
Fullscreen.off();
}
else {
Fullscreen.on();
document.getElementById("GameCanvas").webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
}
')


Alex(Posted 2014) [#8]
Thank you, Paul, it'll may be very useful in future!
I was looking, actually, for the way to load a game in fullscreen already on iPhone and Android.


thoast(Posted 2015) [#9]
Sorry for late answer, but for security reasons, the fullscreen function always requires a triggering user interaction.