567 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Ireland
  • Referred between 10 and 49 users
  • Sold between 10 000 and 50 000 dollars
iamdok says

I’m trying to differentiate between an “exit from Fullscreen Mode” called by a button or by other means. (esc key, ctrl+W on windows, click other window, etc etc)

I’m listening for the FullScreenEvent on the stage and can’t seem to figure out a way to check what exactly triggered the “exit”. The tagret of the event is the stage object in all cases.

It seems pretty simple, but I’m drawing a blank today! The code looks like the following:

function fullScreenHandler(e:FullScreenEvent):void
{
    //check to see if returning from fullscreen
    if(!e.fullScreen)
    {
        //check what triggered the event
        //if its the button - do something
        //if not - do something else
    }
}

Any Ideas? Donagh

8114 posts Community Moderator
  • Attended a Community Meetup
  • Community Moderator
  • Has been a member for 6-7 years
  • United Kingdom
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
  • Contributed a Blog Post
  • Beta Tester
  • Bought between 50 and 99 items
+4 more
MSFX Volunteer moderator says

I’ve never tried to do that but you could listen for KEY _DOWN and if its ESC set a boolean that is then used in your FullScreenEvent handler…?

567 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Ireland
  • Referred between 10 and 49 users
  • Sold between 10 000 and 50 000 dollars
iamdok says

Hey Matt,

It seems that detecting the escape key press is not working inthe browser. Its fine in the IDE but once in the browser the KEY _DOWN event doesn’t fire when using the escape key to return to normal display more. I’ve had this problem before too.

That time I used the resize event, which worked for me but it won’t suffice here. Nor will the FullScreenEvent. Flash Fullscreen and the escape key hjave a buggy relationship.

I’m still trying….

3058 posts
  • Community Superstar
  • Has been a member for 6-7 years
  • Won a Competition
  • Sold between 50 000 and 100 000 dollars
  • Bought between 10 and 49 items
  • Referred between 50 and 99 users
  • Exclusive Author
+1 more
wickedpixel says

Use a proxy function when triggering the Fullscreen event. All the buttons should first call a function that sets a parameter like user_triggered = true; .. and you can use that when you do re-size calculation or what jobs you need. Set it back to false at the end of resize actions.

1160 posts
  • Author had a File in an Envato Bundle
  • Has been a member for 4-5 years
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Referred between 10 and 49 users
  • Bought between 50 and 99 items
FlashTang says
Use a proxy function when triggering the Fullscreen event. All the buttons should first call a function that sets a parameter like user_triggered = true; .. and you can use that when you do re-size calculation or what jobs you need. Set it back to false at the end of resize actions.
fs_btn.addEventListener(MouseEvent.CLICK,mh)
fs_btn1.addEventListener(MouseEvent.CLICK,mh)

stage.addEventListener(Event.RESIZE,resizeHandler)
var user_triggered :Boolean
var _target
function mh(e:MouseEvent):void{
    _target=e.currentTarget
     if(e.currentTarget==fs_btn){
         user_triggered=true
     }
    toFull() 

}

function toFull(){
    stage.displayState==StageDisplayState.NORMAL?
    stage.displayState=StageDisplayState.FULL_SCREEN:
    stage.displayState=StageDisplayState.NORMAL
}
var memory:Boolean=false
function resizeHandler(e:Event):void{
    if(!memoey){
        if(stage.displayState==StageDisplayState.FULL_SCREEN){
            //your code
            memory=true
        }
    }else{

        if(stage.displayState==StageDisplayState.NORMAL){
            //your code
            if(user_triggered){
                //dosomething()
                user_triggered=false
            }else{

                    //...

            }
            memory=false
        }

    }
}

5277 posts The Dude Abides
  • United States
  • Exclusive Author
  • Has been a member for 5-6 years
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Bought between 100 and 499 items
  • Referred between 100 and 199 users
+5 more
CodingJack says

function fullScreen(event:Event):void {

    if(event is FullScreenEvent) {

        // triggered by escape key

    }
    else {

        // event is MouseEvent
        // triggered by button

    }

}

567 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Ireland
  • Referred between 10 and 49 users
  • Sold between 10 000 and 50 000 dollars
iamdok says

Thanks guys for your input.

Finally solved it. The problem was that the esc key was retarded so I couldn’t rely on that. Also I couldn’t use the FullScreenEvent because it was fired even if the user clicked a button to exit fullscreen mode and the target was always the stage. I also didn’t want to use the resize function as it was a bit too messy for me.

What I did was create 2 functions, 1 to toggle fullscreen mode and 1 to be triggered by the fullscreen event. I only add the fullscreenEvent listener when the fullscreen mode was entered (by user click always) therefore it will only be handling the return event and not the enter event. Then if the user clicked to exit, I quickly removed the fullscreen Event listener in the first function so as not to trigger the fullscreenEvent function, then dealt with the button’s state change. So if the user exited fulllscreen mode using any other means the fullscreenEvent’s function would run and handle the button state.

Simplified code:

function linkClick(e:TextEvent):void
{
    toggleFullscreen();
    modifyBtn();
}

//toggle fullscreen
function toggleFullscreen():void
{ 
    //remove fullscreen event listener
    stage.removeEventListener(FullScreenEvent.FULL_SCREEN, fullScreen);

        //toggle 
    if (fullsOn == false) 
    {
        stage.displayState = StageDisplayState.FULL_SCREEN;
        fullsOn = true;
        stage.addEventListener(FullScreenEvent.FULL_SCREEN, fullScreen);
    } 
    else 
    {  
        stage.displayState = StageDisplayState.NORMAL;
        fullsOn = false;
    }

}

//called on fullscreen exit
function fullScreen(e:FullScreenEvent):void
{
    //user exited fullscreen using keyboard
    fullsOn = false;
    modifyBtn();
    stage.removeEventListener(FullScreenEvent.FULL_SCREEN, fullScreen);
}

So this now covers exiting fullscreen mode by any means. (Ctrl+W on windows, Esc key, click another window eg. on a dual monitor setup, user mouse click etc.)

If you’re wondering what the TextEvent is in the first function – my fullscreen button isn’t a button but a hyperlink in a body of html text. Which has it’s own targeting problems :)

So thanks again. Hopefully I won’t be annoying everyone here on the forums again with this fullscreen nonsense !!

Donagh

by
by
by
by
by
by