Groups | Blog | Home
all groups > flash actionscript > march 2004 >

flash actionscript : onKeyPress


tralfaz
3/17/2004 2:50:01 PM
From the reference:
"To use onKeyDown you must create a listener object"

id = new Object();
id.onKeyDown = function ()
{
trace("now it will work");
};
Key.addListener(id);

tf


[quoted text, click to view]

VooDoo Chicken
3/17/2004 10:16:26 PM
i just did what follows:

created a new project, empty stage, only one frame. in the only frame i placed
the next text:

_root.onKeyDown = function() {
trace("algo");
};

what i believe should had happened when running is: i run, nothing appears in
screen but if i press a key (any key), output window should open with a message
'algo', output window never openned, why?
VooDoo Chicken
3/17/2004 11:09:59 PM
tried that, did not work either, tried to place code in a second frame were
object already existed (it may be the case the object did not exist on time for
the declaration) did not work either. tried to change onkeydown by
onclipevent(keydown) and now it works fine, why, i have no idea
KnowMind
3/18/2004 11:28:31 AM
It's because you would have selected a movie clip on the stage and then
tried to assign the code to it, instead of the frame. So select the frame
first and then paste the script on to the action window. It will work.

--KM

[quoted text, click to view]

AddThis Social Bookmark Button