I would like to remove a fullscreen button if the allowfullscreen param is false.
param value="true" name="allowfullscreen"
Does anyone know if its possible to detect that value? It doesn't come with other flashvars on loaderInfo.parameters.
I would like to remove a fullscreen button if the allowfullscreen param is false.
param value="true" name="allowfullscreen"
Does anyone know if its possible to detect that value? It doesn't come with other flashvars on loaderInfo.parameters.
The member you want is
stage.displayState
It can be assigned like so:
import flash.display.StageDisplayState;
....
stage.displayState = StageDisplayState.FULL_SCREEN;
stage.displayState = StageDisplayState.NORMAL;
I recommend reading:
[Edit:
Oh man, totally misread your question.]
After a little test it looks like you can just use the exception mechanism to test for it without any perceptable flicker:
try
{
stage.displayState = StageDisplayState.FULL_SCREEN;
stage.displayState = StageDisplayState.NORMAL;
} catch ( error:SecurityError ) {
// your hide button code
}
You cannot detect if the embed has the allowfullscreen set to false/true.
Unfortunately you will need to wait until the user clicks on the button to catch the eventual error and thereby disable the button.
Still ... You must be in a very special context to require flashplayer evaluate this value itself as you probably edited it. In case the embed is handled by a third-party that needs to be able to decide whether the fullscreen mode should be allowed or not. If this is the case, just add an extra flash-var (e.g. fullscreenButton=false).
The only method i can think of would be to call a JavaScript function via ExternalInterface. You can easily read the flash embed parameters from JavaScript, but I'm thinking if you could insert a JS into the HTML your movie is embedded, you'd have rather changed the parameter than try to find out what it is.
Other than that, Jotham's solution seems ok, aside from the fact that stage.displayState = StageDisplayState.FULL_SCREEN;
can only be triggered by a user event.
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. (http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Stage.html#displayState)
You should have a second button that when pressed, runs Jotham's code. I'd go for a login button or any other button the user would press anyway.
The following will detect if your player has fullscreen availability (thx @mrdoob) :
var hasFullscreen:Boolean = (stage.hasOwnProperty("displayState"))
Sadly, the above post does not work. A swf with:
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);
}
});
}
}
}
Will trace when FullScreen is disabled:
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.
The problem being the Full Screen Enabled? true
part.