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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this possible?

Status
Not open for further replies.

mike314

Programmer
Jun 24, 2003
143
US
Is this possible, can I have an event handler or function that listens for a specific key on the keyboard like the up/down arrows or the "k" button? how can it be done?
 
Code:
mylistener=new Object();
mylistener.onKeyDown=function(){
// 38 represents the key-code for up-arrow
	if(Key.isDown(38)==true){
	trace("up-key pressed");
	}
}
Key.addListener(mylistener)


See this site for all key codes:
regards

tektips.gif
 
or even better:

Code:
mylistener=new Object();
mylistener.onKeyDown=function(){
	if(Key.UP){
	trace("up-key pressed");
	}
}
Key.addListener(mylistener);

regards

tektips.gif
 
hey, anyone know how to end a scene?. I'm working on a game and nahe a movieClip and when you click on it I want to end. Whats the command? END or Kill???

i've checked my actionScripts book and can't find it.

thanks
 
oldnewbie: that would only make the movieClip hidden from sight but not end it right? the movieClip would still be playing in the background.
 
Code:
on(release){
	movieclip.gotoAndStop(movieclip._totalframes);
}

...would jump to the movieclip's last frame.

regards

tektips.gif
 
you could do this.unloadMovie();

Philip Keiter
Senior Flash Software Developer
Sphyrras
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top