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.

bzlm
  • 9,626
  • 6
  • 65
  • 92
jspooner
  • 10,975
  • 11
  • 58
  • 81

8 Answers8

2

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
  • 1,122
  • 1
  • 10
  • 23
  • 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 Mar 20 '09 at 04:47
  • That's just a matter of information design. It's hardly going to inhibit the testing process to any great degree. – Jotham Mar 20 '09 at 05:26
2

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
}
mihai
  • 4,184
  • 3
  • 26
  • 27
  • 3
    stage.allowsFullScreen was added in 10.2 so this won't work for older players, but this is the best solution I've found. I use: stage.hasOwnProperty("displayState") && stage.hasOwnProperty("allowsFullScreen") && stage["allowsFullScreen"] – Sarah Northway Nov 15 '13 at 12:46
0

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 Schoonover
  • 2,763
  • 1
  • 15
  • 8
0

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.

dlamblin
  • 43,965
  • 20
  • 101
  • 140
  • "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 Mar 18 '09 at 22:15
  • The question says "It doesn't come with other flashvars on loaderInfo.parameters". – bzlm Mar 18 '09 at 22:17
  • 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 Mar 20 '09 at 04:49
0

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
  • 8,905
  • 3
  • 24
  • 38
0

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
  • 5,448
  • 6
  • 41
  • 49
-1

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.

haxpor
  • 2,431
  • 3
  • 27
  • 46
-3

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"))
Theo.T
  • 8,905
  • 3
  • 24
  • 38
  • This solution does not work as the displayState property is always available, even when allowFullScreen=false, tested in Flash 10.0. – sixones Dec 10 '10 at 16:49
  • I know, as you can see this was posted 2 years ago while the issue was to detect if the player version actually supported this feature... kthx – Theo.T Dec 30 '10 at 22:48