Detect if fullscreen mode is enabled in ActionScript 3.0?

I want to remove the fullscreen button if allowfullscreen is false.
param value="true" name="allowfullscreen"

Does anyone know if this value can be detected? It does not come with other flashvars on loaderInfo.parameters.

+6
flash actionscript-3 fullscreen flashvars
source share
8 answers

EDIT: now it is deprecated (it was a hack for FP 8.5 / 9)

Below you will find out if your player has full-screen availability (thanks @mrdoob):

 var hasFullscreen:Boolean = (stage.hasOwnProperty("displayState")) 
-3
source share

Do you want to

 stage.displayState 

It can be assigned as follows:

 import flash.display.StageDisplayState; .... stage.displayState = StageDisplayState.FULL_SCREEN; stage.displayState = StageDisplayState.NORMAL; 

I recommend reading:

http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000352.html

[Edit:

Oh man, a completely wrong question.]

After a little test, it looks like you can just use the exception mechanism to check for it without any noticeable flicker:

 try { stage.displayState = StageDisplayState.FULL_SCREEN; stage.displayState = StageDisplayState.NORMAL; } catch ( error:SecurityError ) { // your hide button code } 
+2
source share

SOLUTION FOR AS3

you can check if the full screen is allowed through the properties of the scene, for example, for my case

 try { if (btn.stage["allowsFullScreen"]) { // if this fails, then its not allowed // do full screen allow code here btn.alpha = 1; // show since its allowed } } catch (error:Error) { // full scrren not allowed btn.alpha = 0.5; // dim since it cant be used } 
+2
source share

Actually, the documents are unclear how full-screen mode is allowed or not, in ActionScript 3.

The only thing they are talking about is that if you try to switch to full-screen mode, and this is prohibited, you will get an exception that you can catch. This will not allow you to hide or show the full screen button.

There may be some way, but "residential", as you know, incomplete or short.

Perhaps you can read the value of the "fullscreen" parameter, whose default value is false, if you look at the root parameters of the object:

 var keyStr:String; var valueStr:String; var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters; for (keyStr in paramObj) { valueStr = String(paramObj[keyStr]); //do something with this information } 

Strike> Edit: You noted that it is not returning to flashvars.

0
source share

You cannot determine if the embeddable parameter allowfullscreen is false / true.

Unfortunately, you need to wait until the user clicks on the button in order to catch a possible error and thereby disable the button.

However ... You must be in a special context to require flashplayer to evaluate this value yourself, since you probably edited it. In the event that embedding is handled by a third party, which should be able to decide whether full-screen mode is enabled or not. If so, just add extra flash-var (e.g. fullscreenButton = false).

0
source share

The only method I can think of is to call the JavaScript function via ExternalInterface. You can easily read the parameters of the embedded flash script from JavaScript, but I think that if you can insert JS in the HTML that your movie is embedded in, you would rather change the parameter than try to figure out what it is.

In addition, the Jotham solution seems approved, except that stage.displayState = StageDisplayState.FULL_SCREEN; can only be triggered by a custom event.

Full-screen mode is launched in response to a mouse click or keystroke by a user; a movie cannot modify Stage.displayState without user input. ( http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Stage.html#displayState )

You should have a second button that, when clicked, launches the Jotham code. I would choose the login button or any other button that the user will press anyway.

0
source share

Unfortunately, the above post does not work. From swf to:

 package { import flash.display.Sprite; import flash.display.StageDisplayState; import flash.events.Event; import flash.events.MouseEvent; public class Tester extends Sprite { public function Tester() { trace("Display States: Full="+StageDisplayState.FULL_SCREEN+"; Normal="+StageDisplayState.NORMAL); trace( "- Display State? "+stage.displayState); trace( "- Full Screen Enabled? "+(stage.hasOwnProperty("displayState")) ); stage.addEventListener( MouseEvent.CLICK, function(evt:Event=null):void { trace("Attempting to change to FullScreen..."); try { stage.displayState = StageDisplayState.FULL_SCREEN; trace("Success!"); stage.displayState = StageDisplayState.NORMAL; } catch(e:*) { trace("Fail! "+e); } }); } } } 

Tracked when disabling FullScreen:

 Display States: Full=fullScreen; Normal=normal - Display State? normal - Full Screen Enabled? true Attempting to change to FullScreen... Fail! SecurityError: Error #2152: Full screen mode is not allowed. 

Full Screen Enabled? true problem part of Full Screen Enabled? true Full Screen Enabled? true

0
source share

I believe that we could test this opportunity while trying to listen

 _root.stage.addEventListener(FullScreenEvent.FULL_SCREEN, onFullScreenListenter); 

From my test, trying to enable full-screen mode on a hard security node, it will return an empty exception. I think due to FullScreenEvent does not exist.

-one
source share

All Articles