A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: fixing the ESC button

  1. #1
    Senior Member
    Join Date
    May 2004
    Posts
    322

    fixing the ESC button

    i'm using very simple code such as :


    Quote:
    on(keyPress "<Escape>"){
    _root.prevFrame(); // go back to menu
    }


    so that when i press escape the flash file goes to the menu.

    this code works fine when i test it within flash(8).

    however i am also using:


    Quote:
    fscommand ("fullscreen", "true");
    fscommand ("allowscale", "true");


    to make my program full screen.

    the problem is when i press escape, the flash file escapes out of full screen mode and shows its window rather than run the code i typed in.


    how can i fix this so that pressing escape will keep the game in fullscreen but also run the code to go to menu frame??

  2. #2
    Script kiddie VENGEANCE MX's Avatar
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,590
    Maybe the trapallkeys function/fscommand/whatever might help?
    http://www.birchlabs.co.uk/
    You know you want to.

  3. #3
    Senior Member
    Join Date
    May 2004
    Posts
    322
    does anyone else know what the problem is related to or how it could be fixed? i'm sorry but the above answer doesnt help...

  4. #4
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    Have tried using keyListeners. I know that there sometimes useful.

    code:
    var keyListener:Object = new Object();
    keyListener.onKeyDown = function() {
    if (Key.isDown(Key.ESCAPE)) {
    your action()
    }
    };
    Key.addListener(keyListener);


  5. #5
    Senior Member
    Join Date
    May 2004
    Posts
    322
    i've used the code you have suggested because i already was using keylistener.

    the weird thing is that it works fine when testing it in flash 8 but the swf file doesnt work - it still exits fullscreen mode rather than switching back to menu.

    anyone know why it would work in flash but not in the final swf???

  6. #6
    Senior Member Ray Beez's Avatar
    Join Date
    Jun 2000
    Posts
    2,793
    Well, are you just double-clicking the SWF to run it? That's not how people will be viewing this when you're done. Will you be showing it via a web page or by an EXE?

  7. #7
    Senior Member
    Join Date
    May 2004
    Posts
    322
    it'll be a standalone exe on cd.

  8. #8
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    You tried

    fscommand("trapallkeys","true");

    ( As VENGEANCE mentioned ) ?

    Also I always thought alt-f4 was used to quit out of full-screen projector files. Does the same thing happen when testing it as an exe rather than just a full-screen swf ?

    Squize.

  9. #9
    Senior Member Ray Beez's Avatar
    Join Date
    Jun 2000
    Posts
    2,793
    Esc quits the EXE player.

  10. #10
    Senior Member
    Join Date
    May 2004
    Posts
    322
    sorry guys we might have got our wires crossed -

    the esc button doesnt quit the player but instead it comes out of fullscreen mode - which is not what i want to do.

    i have used code to make the screen fullscreen, and i have used code so when i press esc it goes to the menu.

    however pressing escape in fullscreen mode simply exits fullscreen. HOWEVER the code works fine when testing in flash but not when using a swf or exe....

  11. #11
    Senior Member
    Join Date
    May 2004
    Posts
    322
    anybody any ideas on the above?

  12. #12
    n00b yellowman's Avatar
    Join Date
    May 2002
    Location
    Sweden
    Posts
    163
    For the third time, have you tried "trapallkeys"?

    Did a quick test, this works for me(it dosen´t exit fullscreen when running as standalone).

    Code:
    fscommand("fullscreen",true);
    fscommand("trapallkeys",true);
    // test var
    var count:Number = 0;
    var keyListener:Object = new Object();
    keyListener.onKeyDown = function() {
    	if (Key.isDown(Key.ESCAPE)) {
    		++count;
    	}
    };
    Key.addListener(keyListener);
    But maybe I´m missing something here...?

  13. #13
    Senior Member
    Join Date
    May 2004
    Posts
    322
    ill try that - but i was still wondering why does the original code work within flash but not outside of it?

  14. #14
    Senior Member Ray Beez's Avatar
    Join Date
    Jun 2000
    Posts
    2,793
    Quote Originally Posted by rrrrr_rav
    ill try that - but i was still wondering why does the original code work within flash but not outside of it?
    Alot of things are different when tested within Flash versus using the external player.

  15. #15
    Senior Member
    Join Date
    May 2004
    Posts
    322
    well ok thanks for the help, i'm sure it will help me fix the problem.


    Alot of things are different when tested within Flash versus using the external player.
    that seems a little weird...

  16. #16
    Script kiddie VENGEANCE MX's Avatar
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,590
    I already told you the answer... ¬_¬

    fscommand("trapallkeys", "true");
    http://www.birchlabs.co.uk/
    You know you want to.

  17. #17
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Hopefully he's taken the hint this time

    Squize.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center