You are totally right. After a bunch of readings, it appears that it is a design choice from Adobe to exit fullscreen while pressing escape key on the flash player exe.
Still, I've managed to find an (ugly) method to force staying in full screen :)
First, you got to have a savefile ready for accessing a fullscreen bool from every states:
package common;
import flixel.util.FlxSave;
class SaveFile
{
private static var _save:FlxSave;
private static var _loaded:Bool = false;
private static var _fullscreen:Bool = false;
public inline function new()
{
load();
}
public static function load():Void
{
_save = new FlxSave();
_loaded = _save.bind("savefile");
if (_loaded) {
if (_save.data.fullscreen == null) _save.data.fullscreen = _fullscreen;
} else {
_save.data.fullscreen = _fullscreen;
}
}
public var fullscreen(get, set):Bool;
function get_fullscreen() { if (_loaded) return _save.data.fullscreen; else return _fullscreen; }
function set_fullscreen(bool:Bool) { if (_loaded) return _save.data.fullscreen = bool; else return _fullscreen = bool; }
}
Then you just ask on your state update if the FlxG.fullscreen is equal to your savefile boolean:
import common.SaveFile;
...
private var saveFile:SaveFile = new SaveFile();
...
override public function update(elapsed:Float):Void
{
super.update(elapsed);
if (FlxG.keys.anyJustPressed([122])) // press F11 to go/exit fullscreen
{
saveFile.fullscreen = !saveFile.fullscreen;
FlxG.fullscreen = saveFile.fullscreen;
}
if (saveFile.fullscreen && !FlxG.fullscreen) FlxG.fullscreen = saveFile.fullscreen;
}
That's it. When you press escape to exit your menu or change state, the flash player will exit fullscreen and then go back to fullscreen by itself. But it's very ugly.
Now that I've messed with flash player, it's time to move on to desktop target :)
Thanks Dustin for your time.