As3: Detect Remote Control Buttons using Key Codes


/ Published in: ActionScript 3
Save to your folder(s)

Whenever you press on a remote control button (through wireless), Flash can detect what button is being pressed


Copy this code and paste it in your HTML
  1. stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownHandler);
  2.  
  3. // Key Handling
  4. public function onKeyDownHandler( e:KeyboardEvent ):void
  5. {
  6. trace("Key Down:" + e.charCode + ":" + e.keyCode);
  7.  
  8. switch( e.keyCode )
  9. {
  10. case 16777227: // rev
  11. break;
  12.  
  13. case 16777226: // fwd
  14. break;
  15.  
  16. case 16777223: // play
  17.  
  18. case 13: // ok,enter
  19. break;
  20.  
  21. case 16777225: // stop
  22.  
  23. break;
  24.  
  25. case 16777224: // pause
  26.  
  27. break;
  28.  
  29. case 16777220: // ch+
  30.  
  31. case 38: // up
  32. break;
  33.  
  34. case 16777221: // ch-
  35.  
  36. case 40: // down
  37. break;
  38.  
  39. case 62720: // A - remote
  40.  
  41. case 65: // A - keyb
  42.  
  43. case Keyboard.RIGHT:
  44. break;
  45.  
  46. case Keyboard.LEFT:
  47. break;
  48. }
  49. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.