Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

on(keyPress "<Enter>"){

Status
Not open for further replies.

netchen

Technical User
Joined
Apr 19, 2005
Messages
21
Location
AU
hi!

i am doing an application where only the keyboard should be used. it all works fine with the direction buttons on the keyboard (left, right, up, down) but when i want to enable the enter button it doesn't work. i want the movie to jump to a specific frame or play a specific mc when the enter button is clicked. the code on one button is ie:

Code:
     on(keyPress "<Left>"){
	  gotoAndStop(10);
     }

     on(keyPress "<Down>"){
	  gotoAndStop(3);
     }

     on(keyPress "<Enter>"){
	  _root.mc_test.gotoAndStop(2);
     }

it works fine to got left and right but when i press the enter button it always jumps to the next frame of the main timeline and doesn't recognise what i want it to do.

any suggestions?

thanks

netchen
 
might be better to use a key listener

myListener = new Object();
myListener.onKeyDown = function() {
if (Key.getCode() == Key.ENTER) {
_root.mc_test.gotoAndStop(2);
}
};
Key.addListener(myListener);
 
sorry just tested the above and i cant explain why its not working

i added a trace and got the correct value for all other keys but nothing at all for enter

myListener = new Object();
myListener.onKeyDown = function() {
trace(key.getCode())
if (Key.getCode() == key.ENTER) {
trace("ENTER");
}
};
Key.addListener(myListener);
 
i just tried it as well and nothing happens? how is that possible???
 
for some reason it works fine in a published movie but not in the authoring environment. publish the movie and all is well. strange.
 
thanks! it works well now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top