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.
EDIT: This is obsolete now (was a hack for FP 8.5 / 9)
The following will detect if your player has fullscreen availability (thx @mrdoob) :
var hasFullscreen:Boolean = (stage.hasOwnProperty("displayState"))
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
}
SOLUTION FOR AS3
you can check if full screen is allowed via the stage properties, 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
}
Actually the docs are unclear as to how full screen mode being allowed or not can be detected in ActionScript 3.
The only thing they mention is that if you do try to switch to full screen mode and it is disallowed, then you'll get an exception, which you can catch. This won't easily allow you to hide or show a full screen mode button.
There may be a way, but the "livedocs" are notoriously incomplete or brief.
You might be able to read the "fullscreen" param's value which defaults to false by looking at the root object's paramters with:
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
}
Edit: you noted that it doesn't come back in the flashvars.
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.
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.
I believe we could check this capability with the try to listen to the
_root.stage.addEventListener(FullScreenEvent.FULL_SCREEN, onFullScreenListenter);
From my test on trying to allow for full screen mode in tight security set host, it will return null exception. I guess because of FullScreenEvent is not exist.
EDIT: This is obsolete now (was a hack for FP 8.5 / 9)
The following will detect if your player has fullscreen availability (thx @mrdoob) :
var hasFullscreen:Boolean = (stage.hasOwnProperty("displayState"))
© 2022 - 2024 — McMap. All rights reserved.