Be a Supporter!

Custom XKey Class

  • 1,993 Views
  • 14 Replies
New Topic Respond to this Topic
authorblues
authorblues
  • Member since: Jun. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Custom XKey Class Nov. 18th, 2005 @ 04:21 AM Reply

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
Claxor
Claxor
  • Member since: Oct. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Custom XKey Class Nov. 18th, 2005 @ 04:43 AM Reply

Nice, good for the lazy


BBS Signature
Devenger
Devenger
  • Member since: Dec. 24, 2004
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Custom XKey Class Nov. 18th, 2005 @ 06:15 AM Reply

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.

stickmoose
stickmoose
  • Member since: Mar. 10, 2003
  • Offline.
Forum Stats
Member
Level 19
Blank Slate
Response to Custom XKey Class Nov. 18th, 2005 @ 08:37 AM Reply

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

authorblues
authorblues
  • Member since: Jun. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Custom XKey Class Nov. 18th, 2005 @ 09:06 AM Reply

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
FatStefan
FatStefan
  • Member since: Nov. 11, 2005
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Custom XKey Class Nov. 18th, 2005 @ 09:10 AM Reply

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

GuyWithHisComp
GuyWithHisComp
  • Member since: Nov. 10, 2005
  • Offline.
Forum Stats
Member
Level 28
Blank Slate
Response to Custom XKey Class Nov. 18th, 2005 @ 12:11 PM Reply

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
dELtaluca
dELtaluca
  • Member since: Apr. 16, 2004
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to Custom XKey Class Nov. 18th, 2005 @ 12:37 PM Reply

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
authorblues
authorblues
  • Member since: Jun. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Custom XKey Class Nov. 18th, 2005 @ 01:06 PM Reply

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
authorblues
authorblues
  • Member since: Jun. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Custom XKey Class Nov. 18th, 2005 @ 01:07 PM Reply

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
liam
liam
  • Member since: Dec. 11, 2004
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to Custom XKey Class Nov. 18th, 2005 @ 01:17 PM Reply

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
authorblues
authorblues
  • Member since: Jun. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Custom XKey Class Nov. 18th, 2005 @ 01:20 PM Reply

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
authorblues
authorblues
  • Member since: Jun. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Custom XKey Class Nov. 18th, 2005 @ 01:22 PM Reply

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
liam
liam
  • Member since: Dec. 11, 2004
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to Custom XKey Class Nov. 18th, 2005 @ 01:26 PM Reply

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


Sup, bitches :)

BBS Signature
authorblues
authorblues
  • Member since: Jun. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Custom XKey Class Nov. 18th, 2005 @ 06:12 PM Reply

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