A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: keyboard event listener

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    1

    keyboard event listener

    Hi, I noticed that everyone one creates a thread for their asks rather than there being a central thread to post them in, so I'm going to do that too.

    I have had flash CS5.5 for a week or 2 now, it uses AS3, seeing as that is the latest action script version that's the one I would like to learn how to use.
    However, my town is sort of excluded from the rest of the world and the only guide I could get my hands on was for AS2, so I do the practice excersises in it and if a compilation error hits I look it up on the internet to see if it has anything to do with the code being out of date.
    But now I have stranded,

    Code:
    import flash.events.KeyboardEvent;
    
    var snelheidSpaceShip:Number = 10;
    
    spaceship_mc.addEventListener(KeyboardEvent.Key.LEFT, key1);
    function key1(event:KeyboardEvent):void {
    	trace("links ingedrukt");
    }
    He doesn't recognize the instance name of my movieclip and apparently Key.LEFT doesn't exist?
    Can anyone give me an educated opinion?

  2. #2
    Member
    Join Date
    Aug 2012
    Posts
    55

    keyboard event listener

    Keyboard.Left should work or you can use 37 as the keyboard left keycode.

    you might need all three of the following imports:

    import flash.events.Event;
    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;

    check out this link http://edutechwiki.unige.ch/en/AS3_e...yboard_control
    Last edited by rachelg; 10-13-2012 at 01:07 PM.

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