Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-26-2012, 07:27 AM   PM User | #1
Shas'O kias
New to the CF scene

 
Join Date: Mar 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Shas'O kias is an unknown quantity at this point
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
Shas'O kias is offline   Reply With Quote
Old 03-28-2012, 01:48 AM   PM User | #2
adaminaudio
New Coder

 
Join Date: Jan 2012
Location: Columbus, Ohio, U.S.A
Posts: 41
Thanks: 0
Thanked 8 Times in 8 Posts
adaminaudio is an unknown quantity at this point
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!!

        }
}
adaminaudio is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:54 AM.


Advertisement
Log in to turn off these ads.