00:00
00:00

Custom XKey Class

2,724 Views | 14 Replies
New Topic Respond to this Topic

Custom XKey Class 2005-11-18 04:21:42


custom XKey class

sure, youve all seen people asking how to get their Key.isDown functions to work properly. well, for no one in particular, ive created a class called XKey, which is an extended key mapping to simplify the process.

note: this is not necessary for anyone who knows how to use a Key.isDown() function properly, or anyone who is only checking for one or two keys. this extended mapping includes 50 extra keys, so its a bit of overkill...

how to use:

download the zipped file here: XKey.zip
(sorry for using that god-awful site. i didnt know where else to put it)
extract the XKey.as file to the same directory as your fla file.

how to call the file from within your fla:

var exKey:XKey = new XKey();
this will give the variable exKey all the methods of the XKey class.
in order to check for a key down, just call the corresponding method:
(this code will check to see if the A key has been pressed down)

if (exKey.A()){
// actions
}

its that simple. the available keys are as follows:

A thru Z, called with A() thru Z()
0 thru 9 (above the home keys), called with KEY_0() thru KEY_9()
0 thru 9 (on the numpad), called with NUM_0() thru NUM_9()
+ and - (above the home keys), called with PLUS() and MINUS()
+ and - (on the number pad), called with NUM_PLUS() and NUM_MINUS()


BBS Signature

Response to Custom XKey Class 2005-11-18 04:43:01


Nice, good for the lazy


BBS Signature

Response to Custom XKey Class 2005-11-18 06:15:29


I actually thought of doing something like this myself. Very impressive and useful, although I'm still hardcore keycodes (55 = A, 58 = D, and all the others still get me).

You can sing that bracketed bit, teeheehee

I'm back! on a temporary basis. No-one can remember who I am! but I don't really mind.

Response to Custom XKey Class 2005-11-18 08:37:36


Cool, I think delta already made a better version of this though.

Response to Custom XKey Class 2005-11-18 09:06:55


At 11/18/05 08:37 AM, stickmoose wrote: Cool, I think delta already made a better version of this though.

by better do you mean larger, because i really tried to keep it at the bare minimum, by including the letters and numbers. any more than that, and it would just be a ridiculously sized class file.

this is not meant for the forum regulars to download and start using. i was hoping this would become one of AS: Main's useful links, so that, if someone came in saying "ZOMG, i dont know how to use a Key.isDown, and i want to have the ASWD-keys move my character", all youd do is send them here, and theyd have a simple resource to solve their problem...

...or not...

BBS Signature

Response to Custom XKey Class 2005-11-18 09:10:53


Cool I made basically the same thing earlier last week. Great job!

Response to Custom XKey Class 2005-11-18 12:11:51


At 11/18/05 06:15 AM, Devenger wrote: 55 = A, 58 = D

Well, A = 65 and D = 68 :P

Nice job, authorblues :)


BBS Signature

Response to Custom XKey Class 2005-11-18 12:37:25


At 11/18/05 09:06 AM, authorblues wrote:
At 11/18/05 08:37 AM, stickmoose wrote: Cool, I think delta already made a better version of this though.
by better do you mean larger, because i really tried to keep it at the bare minimum, by including the letters and numbers. any more than that, and it would just be a ridiculously sized class file.

no, i didnt make a class like this:
what i did was i made a class with the normal onKeyDown and onKeyUp, but then added two more, onKeyHold and onKeyTap (holding the key for half a second i think it is, or double tapping within half a second of previous tap)


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature

Response to Custom XKey Class 2005-11-18 13:06:25


At 11/18/05 12:37 PM, dELta_Luca wrote: what i did was i made a class with the normal onKeyDown and onKeyUp, but then added two more, onKeyHold and onKeyTap (holding the key for half a second i think it is, or double tapping within half a second of previous tap)

thats very smart. i think i might try something like that. very useful, i would think.
i could see a few applications for that (maybe ddr-style, with holds and stepfiles)...


BBS Signature

Response to Custom XKey Class 2005-11-18 13:07:48


At 11/18/05 09:10 AM, FatStefan wrote: Cool I made basically the same thing earlier last week.

something deep-seated within me wants to doubt that...

Great job!

thanks, but praise me not. this was the product of my 4am boredom...


BBS Signature

Response to Custom XKey Class 2005-11-18 13:17:44


Any chance you could put the file here? Just save it as a .txt first, MegaUpload won't work for me.


Sup, bitches :)

BBS Signature

Response to Custom XKey Class 2005-11-18 13:20:03


At 11/18/05 01:17 PM, -liam- wrote: Any chance you could put the file here?

for you, -liam-, any thing
http://aaron.ntnetwo..d/files/9427xkey.txt

ROFFLES && <3

BBS Signature

Response to Custom XKey Class 2005-11-18 13:22:04


At 11/18/05 04:21 AM, authorblues wrote: its that simple. the available keys are as follows:

A thru Z, called with A() thru Z()
0 thru 9 (above the home keys), called with KEY_0() thru KEY_9()
0 thru 9 (on the numpad), called with NUM_0() thru NUM_9()
+ and - (above the home keys), called with PLUS() and MINUS()
+ and - (on the number pad), called with NUM_PLUS() and NUM_MINUS()

i also forgot to mention that the comma and period, near the spacebar, are also available, called with the functions COMMA() and PERIOD() (respectively). that would bump the number of supported keys to 52...


BBS Signature

Response to Custom XKey Class 2005-11-18 13:26:08


Hmm, pretty cool but you shoulda extended the Key class so you can use the Key keys too =P


Sup, bitches :)

BBS Signature

Response to Custom XKey Class 2005-11-18 18:12:57


At 11/18/05 01:26 PM, -liam- wrote: Hmm, pretty cool but you shoulda extended the Key class so you can use the Key keys too =P

can someone explain to me how to get it to work properly. dont you just change the class initialization to:

Class XKey extends Key{

if so, can someone explain to me how to use this? its just not working for me. im trying to make this as powerful as possible, and liams suggestion is perfect. any help is appreciated.


BBS Signature