Groups | Blog | Home
all groups > flash actionscript > october 2007 >

flash actionscript : Beginner ActionScript



fanglinyong
10/27/2007 12:00:00 AM
JoeLongstreet
10/27/2007 4:03:09 AM
I'm trying to create an interactive movie where the user presses a key and a
certain action occurs. It works great when I use the space bar or arrow keys
as the hot key but I need the movie to react when the letter A is pressed.
Simple solution?
kglad
10/27/2007 5:51:47 AM
JoeLongstreet
10/27/2007 5:07:04 PM
Sorry if I did not define the problem very clearly. There are 9 movie clips
that I want to control on the stage. If I enter this chunk of code to an
invisible button on the stage:

on (keyPress "<Space>") {
_root.redBox.gotoAndPlay(2);
}

I am able to then play one of the movie clips. Instead of being played by the
space bar, I want the movie to be played with the letter "A". I want the next
movie clip to be played by the letter "B" and so on.
kglad
10/27/2007 5:17:11 PM
if you're using as2, you should be using the key class so you don't need any
buttons (visible or not) and can code everything in one place and more
succinctly:



this.onKeyDown=function(){
if(Key.getAcsii()==65){
_root.redBox.gotoAndPlay(2);
} else if(Key.getAcsii()==67){
_root.nextMovie.gotoAndPlay(2);
} else if(...}
}
Key.addListener(this);
JoeLongstreet
10/27/2007 5:29:35 PM
Thanks for your help, it's now working. I didn't know about the Ascii codes

kglad
10/29/2007 5:02:58 AM
AddThis Social Bookmark Button