How to use Skyboy’s custom Key class.

Posted: November 19, 2010 in AS3, Custom Classes, Intermediate, Skyboy

As a developer almost all games will require some form of key control. And after making a few games I can guarantee that you will become tired of adding event listeners and booleans for each key that is needed.  I have gone thru many sad custom key classes and have discovered that the best key class is…. Skyboy’s!

Skyboy’s Key Class is easy to set up and even easier to use. Download  it below and extract it to the desktop:

https://github.com/skyboy/AS3-Utilities/tree/master/skyboy/

After it has been downloaded and extracted, make a folder on the C drive. Call it “Custom Classes”. Drag the folder you downloaded to the Custom Classes folder. After that, launch Flash Develop and go to the project window.

On the right hand side of your screen you should see a project manager pane. Right click on your project and select Properties > Classpaths > Edit Global Classpaths . Push the add classpaths button and add “C:\Custom Classes” .

Congratulations! You have made it easy to add custom classes in the future!

Now to implement the Custom Class.

First you need to import it at the top of your main class:

import skyboy.ui.Key;

In the main class function add the following to have the class listen for keypresses:

Key.listen(stage)

Now whenever you want to have an action for a specific keypress just add the following to the function of your choice:

if (Key.isDown(Key.WHATEVERKEYYOUWANT))
{

PERFORM A SPECIFIC ACTION
}

That’s it! Simple wasn’t it?

Advertisements
Comments
  1. Excellent piece of writing, l quite agree with your submission. I will subscribe to your rss to keep up.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s