A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: button link to keyboard

  1. #1
    Junior Member
    Join Date
    Mar 2008
    Posts
    26

    button link to keyboard

    I have 7 flash button like following:
    http://www.oniva.com/upload/1356/bu.jpg

    each button has on (release) function when button is clicked some event occur
    http://www.oniva.com/upload/1356/bu2.jpg

    But how can I link button to "UP" "DOWN" and "ENTER" key of my keyboard?

    "UP" = high light next button = mouse over
    "DOWN" = high light previous button = mouse over
    "ENTER" = click on the button

  2. #2
    Member
    Join Date
    Mar 2008
    Posts
    82
    addEventListener(Event:KeyboardEvent, doSomething);

    function doSomething(e:Event) :void {

    }

  3. #3
    Member
    Join Date
    Mar 2008
    Posts
    82
    Oops, ignore that. I pressed the tab key and waddaya know, it posted.

  4. #4
    Member
    Join Date
    Mar 2008
    Posts
    82
    Try this as a template. Just replace the trace statements with whatever it is you want to do. This method also makes it nice and simple to add extra keys to the function.

    PHP Code:
    stage.addEventListener(KeyboardEvent.KEY_DOWNkeyboardHandler);

    function 
    keyboardHandler(event:KeyboardEvent) {
        switch (
    event.keyCode) {
            case 
    Keyboard.UP:
            
    trace("Up")
            break
        
            case 
    Keyboard.DOWN:
            
    trace("Down")
            break
            
            case 
    Keyboard.ENTER:
            
    trace("Enter")
            break
        }

    Hope that helps

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