View Full Version : on KeyPress event
Raphaela
06-21-2005, 04:12 PM
Why doesn't flash like either of these? (the second being from FLMX04 Bible p582 except the trace line replaces stop();)
on (keyPress "<ENTER>") {
trace("the enter key was pressed");
};
OR
on (release, keyPress "<ENTER>") {
trace("the enter key was pressed");
};
Thanks.
Raph
Ruben
06-21-2005, 04:40 PM
I dunno, just try to use Key.isDown (http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary407.html) in combination with a listener (look into what the online as-dictionary has to say about the Key-object (http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary393.html).
:) - Ruben
Raphaela
06-21-2005, 04:53 PM
All I want to do, and maybe the as tags messed it up..
....is test the movie, and when I hit enter (or at this point ANY key!!),
"the enter key was pressed" comes up in the OUTPUT window of flash.
:confused: How DUMB am I feeling right now.
Gibberish
06-21-2005, 05:26 PM
for some reason I tend to run into errors when using the ENTER key on about 1/2 the machines I test on. It just tends not to read the ENTER key.
// ----- Key Listener
keyListener = new Object();
// on keyDown
keyListener.onKeyDown = function () {
if(Key.isDown(Key.SPACE)) {
trace('enter pressed');
}
}// End onKeyDown Function
Key.addListener(keyListener);
// ----- End Key Listener
Dylan Marvin
06-21-2005, 05:27 PM
Use the above tip from Ruben, who I think is talking about this kind of thing:
if(Key.isDown(Key.ENTER)){
trace("the enter key was pressed");
}
Ruben
06-21-2005, 05:46 PM
Use the above tip from Ruben, who I think is talking about this kind of thing:What I had in mind was actually the exact same thing that gibberish posted...
:rolleyes: - Ruben
Gibberish
06-21-2005, 06:04 PM
you would have to wrap Dylan's posted code in an onEnterFrame (which isnt recommended) or in a keyListener such as I posted previously.
You can read more on keyListeners: http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary394.html
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.