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 to the CF scene
    Join Date
    Mar 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    assistance required

    hello, i am new to coding however I am currently creating a small two player RST game. because its a 2 player game i was thinking of using the keypad as a mouse, the ownly problem this raises is when it comes to buttons. so my question is can i use a movie clip to make a button work?

    any help would be much appriciated

  • #2
    New Coder
    Join Date
    Jan 2012
    Location
    Columbus, Ohio, U.S.A
    Posts
    41
    Thanks
    0
    Thanked 8 Times in 8 Posts
    hi there,

    I'm hoping that you mean you would like to control a movieclip with a keyboard button instead of the other way around.

    In this case, what you need is a keyboard listener on your movieclip.

    first you add the listener and pass in the name of the handler you will write
    Code:
    addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
    then, you write the handler and you're good to go.

    Code:
    function keyDownHandler(event:KeyboardEvent):void
    {
           if(event.keycode == 86)   //looking for a 'v' button to be pressed
           {
              
                //do awesome stuff here!!
    
            }
    }


  •  

    Posting Permissions

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