A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [RESOLVED] Key.isDown not Working in HTML

  1. #1
    Member
    Join Date
    Sep 2009
    Posts
    57

    resolved [RESOLVED] Key.isDown not Working in HTML

    Ok, I have this code in my movie and everything works fine, except when I go to view my movie in HTML. When in HTML, the Key.isDown function does not work. Here is my code:
    Code:
    keyListener = new Object();
    keyListener.onKeyDown = function():Void  {
        if (Key.isDown(Key.ESCAPE)) {
            normal_video();
    		fs.gotoAndStop(1);
    		fs._x = 863.9;
    		nsB._x = 3000;
    		theatre.gotoAndStop(1);
        }
    };
    Key.addListener(keyListener);
    all help would be appreciated. Thanks in advance.

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    The code works in the browser as long as the swf has focus, i.e., you have to click on it.

    On a side note... I prefer the following conditional:
    actionscript Code:
    if (Key.getCode() == Key.ESCAPE) {

  3. #3
    Member
    Join Date
    Sep 2009
    Posts
    57
    Quote Originally Posted by nunomira View Post
    hi,

    The code works in the browser as long as the swf has focus, i.e., you have to click on it.

    On a side note... I prefer the following conditional:
    actionscript Code:
    if (Key.getCode() == Key.ESCAPE) {
    So this would be my new code:
    Code:
    keyListener = new Object();
    keyListener.onKeyDown = function():Void  {
        if (Key.getCode() == Key.ESCAPE) { 
            normal_video();
    		fs.gotoAndStop(1);
    		fs._x = 863.9;
    		nsB._x = 3000;
    		theatre.gotoAndStop(1);
        }
    };
    Key.addListener(keyListener);

  4. #4
    Senior Member
    Join Date
    Jul 2001
    Location
    San Jose California
    Posts
    144
    danddleo, unsure if you have solved your issue, but I was curious if you were trying to use the escape key to get out of fullscreen video aka - Stage.displayState

    If you are using fullscreen mode, that captures the escape key so keylisteners wont work. Instead use onFullScreen boolean to fire off whatever functions.

  5. #5
    Member
    Join Date
    Sep 2009
    Posts
    57
    Quote Originally Posted by bgregus View Post
    danddleo, unsure if you have solved your issue, but I was curious if you were trying to use the escape key to get out of fullscreen video aka - Stage.displayState

    If you are using fullscreen mode, that captures the escape key so keylisteners wont work. Instead use onFullScreen boolean to fire off whatever functions.
    the escape button will always exit fullscren mode, what i need is a function to be activitaded once the escape key is pressed. it works fine when viewing it on adobe flash player. however once it is installed in HTML the function does not work.

  6. #6
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    don't track the escape key (you can't) track the Stage.displayState.

    gparis

  7. #7
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    it works fine when viewing it on adobe flash player. however once it is installed in HTML the function does not work.
    Works fine for me...
    Attached Files Attached Files

  8. #8
    Member
    Join Date
    Sep 2009
    Posts
    57
    Quote Originally Posted by nunomira View Post
    Works fine for me...
    Do you think it has to do with the fact that the function is not loacted in the main timeline. I tried it again, but it did not work. If I send you the file, could you help out more?

Tags for this Thread

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