View Full Version : AS for key press
cgustin
02-20-2006, 10:14 PM
Hello all...
I am creating a presentation out of flash, and I need to set this up like a next slide type of thing, and I don't want to add a button to attach an action to tell it to go to a new swf file, wondering how I can program it so someone can sit at the computer and just hit the left and right arrow keys to advance the "slide?"
Thanks much!
If you search the forums you will find some good results, here are a few
http://www.actionscript.org/forums/showthread.php3?t=96795
http://www.actionscript.org/forums/showthread.php3?t=90902
cgustin
02-20-2006, 11:27 PM
Thanks. I was messing around and I got this to work--
on(keyPress "<Right>"){
gotoAndPlay('underwriting');
}
But how do I make a second right arrow go to say 'test' ??
Also, how do I make it go back if I want? I know you can just do the 'left' but how does it know what frame to go back to?
Referring to your links, I am not good with AC so I don't understand the whole listener thing. Sorry for being a bone head! I just want to be able to hit the arrow key left or right to advance or go back. But I don't know how to make it know which frame to go back to. I appreciate it. Oh I am in Flash 8, so I am assuming my AC that I did use that worked is a bit outdated.
you add a listener...then write an "if" statement.
cgustin
02-21-2006, 03:44 PM
I am sorry, I have never done this before so I am not sure how to go about it, can you elaborate for me? I appreciate it very much!
cgustin
02-21-2006, 06:12 PM
I saw someone else's post, so I added this to the actions
keyObj = new Object();
keyObj.onKeyDown = function() {
if(Key.getCode() == 32) { // space bar
goForward();
} else if(Key.getCode() == 39) { // right arrow
goForward();
} else if(Key.getCode() == 37) { // left arrow
goBackward();
}
};
I am getting an error of this:
**Error** Symbol=mc_contentBackgnd, layer=fake button2, frame=1:Line 1: Statement must appear within on handler
keyObj = new Object();
**Error** Symbol=mc_contentBackgnd, layer=fake button2, frame=1:Line 2: Statement must appear within on handler
keyObj.onKeyDown = function() {
Shouldn't this part of the code work???
cgustin
02-24-2006, 04:13 PM
Can anyone out there help me? I have a deadline approaching and not sure how to complete this action. Thanks so much!
var keyListener = {};
keyListener.onKeyDown = function()
{
var theKey = Key.getCode();
trace( "keyCode: " + theKey );
switch( theKey )
{
case 32 :
goForward();
break;
case 39 :
goForward();
break;
case 37 :
goBackward();
break;
}
};
Key.addListener( keyListener );
cgustin
02-24-2006, 06:36 PM
Wow that was quick. Thanks so much!
falltimemusic
02-24-2006, 06:36 PM
I'm working with Flash Lite 1.0 and im trying to access a key event from a phone or PDA, it seems that Flash Lite is a form of Flash 4. When I try using listeners it comes up with errors. Has anyone here dealt with this before? any info or point in the right direction would be appreciated.
I found this, it might help
http://www.video-animation.com/flashlite_06.shtml
falltimemusic
02-24-2006, 09:27 PM
I found out that you have to put a button off to the side of the stage that recieves on the onPress events. I can't wait for flash lite 2.0 to come out, so we can all use actionscript 2.0... im not sure if thats true or not, but i think it is.
|
vBulletin® v3.8.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.