-
Incredibly stupid question
What's the easiest way to convert 'A' to 65?
No ord() in 3.0, and the string methods are a total hassle.
-
lemon juice hurts your eyes
PHP Code:
function convert(glyph:String):int { return glyph.charCodeAt(0); }
trace(convert("A")); // returns 65
You were trying to convert to unicode right? (where A = 65)
Florian Vanthuyne
WAR AGAINST SOLVED THREADS
mark yours as Resolved under Thread Tools!
-
Yeah... I just want some static variables to define the key numbers of various keys >.>
Keyboard.A and such only works in AIR.
It seems retarded to have to write a random function to convert chars to ints... this is way I hate virtual machines.
CHARS AND INTS ARE THE SAMETHING YOU STUPID MACHINE!!
-
lemon juice hurts your eyes
You could always hook up an EventListener for KeyboardEvents to the stage and than to a switch case:
PHP Code:
function keyboardHandler(e:KeyboardEvent):void { trace(e.keyCode); // you will have to hardcode the values, so trace them first switch(e.keyCode) { case 65: // do stuff when A is pressed break; // copy & paste case x: .. break; as much as you want for every value } }
Florian Vanthuyne
WAR AGAINST SOLVED THREADS
mark yours as Resolved under Thread Tools!
-
Right, that's what I'm doing.
But using non-constants is iffy at best, and I'd like to set up a simple virtual key system. This means that instead of "65" I need to use "Key.Left", which in turn is defined as "65" with the option of being updated to fit the player's keyboard layout.
It's not a hugely huge deal no, but it is a pain in the ass *nods*
-
lemon juice hurts your eyes
What exactly do you mean with "being updated to fit the player's keyboard layout"?
Florian Vanthuyne
WAR AGAINST SOLVED THREADS
mark yours as Resolved under Thread Tools!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|