Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

on(keypress ...)... how to use keycode?

LEGEND ,
Dec 15, 2008 Dec 15, 2008
Hi all,
I need to update an old application where I can to control some objects at
runtime.
The old application used the

on(keypress "<right>") {
bla;
bla;
bla;
}

to move the selected object to the right.
All went ok this way.

But now I need to use the numpad keys to move the object along diagonals,
up, down, right and left.

Is there a way to use the keypress command and specify a character code for
the numpad keys?

I've read the livedocs on adobe websites but it seems I need to rewrite the
whole thing.

Is there a simpler way to update this application without rewriting it from
the ground up?

TIA

tony
TOPICS
ActionScript
492
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 15, 2008 Dec 15, 2008
You should be able to use the ASCII key codes to control your object. If not im sure you can build a listener that can listen for the ASCII codes you are after and run each function as it recieves them, I could be wrong but hope this helps

Damien
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 16, 2008 Dec 16, 2008
> You should be able to use the ASCII key codes to control your object.[snip]
> Damien

Thx, Damien,
do you know the right syntax to use with "keypress"; I tried everything:

on(keypress 102){
bla...;
bla...;
bla...;
}

or

on(keypress "102"){
bla...;
bla...;
bla...;
}

or

on(keypress charcode(102)){
bla...;
bla...;
bla...;
}
...
...but nothing worked...

Ciao ;).

tony
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 16, 2008 Dec 16, 2008
LATEST
I think this is what your after.

http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Part...

In this code, they are creating a listener to listen for the keydown event in which they run that function that gets the key codes and/or ASCII codes. From this you could create if statements to control your object based on the keycodes your code "gets".

You may have to do a little bit of fiddling with your sequence of functions but shouldnt be 2 hard.

Hope this helps you.

Damien
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines