Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2011
    Location
    United Kingdom
    Posts
    74
    Thanks
    2
    Thanked 3 Times in 3 Posts

    key stroke, Object() and Key() object - error message.

    Hello,

    I am new to Action Script. I try to do something simple, just pressing a key and get a message in the output in Flash.

    Code:
    For this I tried first this:
    var keyListener:Object = new Object();
    keyListener.onKeyDown = function() {
        if (Key.isDown(Key.BACKSPACE)) {
        trace("you pressed the Backspace key.");
        } else {
        trace("you DIDN'T press the Backspace key.");
        }
    };
    Key.addListener(keyListener);

    This doesn't seem to have any errors, but it hasn't any output, as well.

    I googled it and I found: It has to be attached to the root Object and not to a key frame. But if this is why it is not working how do I attach it to the right object?

    Thank you for your help!

  • #2
    New Coder
    Join Date
    Sep 2011
    Location
    United Kingdom
    Posts
    74
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Now I tried it this way:

    on(keyPress "") {
    trace("Hello World");

    }

    But I get an error message:

    "Mouse events are permitted only for button instances"


  •  

    Posting Permissions

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