views:

2348

answers:

6

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.

+2  A: 

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:

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

[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   
}
Jotham
Actually running in the browser, under the flash player plugin, you can't even do this code unless it's attached to a user initiated event like MouseEvent.CLICK.
dlamblin
That's just a matter of information design. It's hardly going to inhibit the testing process to any great degree.
Jotham
A: 
dlamblin
"This won't easily allow you to hide or show a full screen mode button" - why not? If you catch a SecurityException while toggling full screen mode, it's not allowed.
bzlm
The question says "It doesn't come with other flashvars on loaderInfo.parameters".
bzlm
Logic. What if you don't get an exception? Now you're switching modes BEFORE you drew the button and before anyone clicked on it.Except of course: the security model says you can't assign stage.displayState unless initiated by a user event. Yes I missed the flashvars bit when editing in more.
dlamblin
A: 

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).

Theo.T
A: 

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.

evilpenguin
A: 

The following will detect if your player has fullscreen availability (thx @mrdoob) :

var hasFullscreen:Boolean = (stage.hasOwnProperty("displayState"))
Theo.T
A: 

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.

David Alan