Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-20-2006, 10:14 PM   #1
cgustin
Registered User
 
Join Date: Feb 2006
Posts: 6
Default AS for key press

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!
cgustin is offline   Reply With Quote
Old 02-20-2006, 10:23 PM   #2
Cota
Super Moderator
 
Cota's Avatar
 
Join Date: Jul 2001
Location: NYC
Posts: 10,175
Default

If you search the forums you will find some good results, here are a few
http://www.actionscript.org/forums/s...d.php3?t=96795
http://www.actionscript.org/forums/s...d.php3?t=90902
__________________
Color Wars™ | (kul′ər wôrs) n. - Open conflict between factions. www.theColorWars.com

cota - www.chadworkman.com | http://shavedplatypus.com
occupation: designer | flash developer | server-side developer (php, asp, mssql, mysql)
Cota is offline   Reply With Quote
Old 02-20-2006, 11:27 PM   #3
cgustin
Registered User
 
Join Date: Feb 2006
Posts: 6
Default

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.

Last edited by cgustin; 02-20-2006 at 11:31 PM.
cgustin is offline   Reply With Quote
Old 02-20-2006, 11:30 PM   #4
Cota
Super Moderator
 
Cota's Avatar
 
Join Date: Jul 2001
Location: NYC
Posts: 10,175
Default

you add a listener...then write an "if" statement.
__________________
Color Wars™ | (kul′ər wôrs) n. - Open conflict between factions. www.theColorWars.com

cota - www.chadworkman.com | http://shavedplatypus.com
occupation: designer | flash developer | server-side developer (php, asp, mssql, mysql)
Cota is offline   Reply With Quote
Old 02-21-2006, 03:44 PM   #5
cgustin
Registered User
 
Join Date: Feb 2006
Posts: 6
Default

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 is offline   Reply With Quote
Old 02-21-2006, 06:12 PM   #6
cgustin
Registered User
 
Join Date: Feb 2006
Posts: 6
Default

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 is offline   Reply With Quote
Old 02-24-2006, 04:13 PM   #7
cgustin
Registered User
 
Join Date: Feb 2006
Posts: 6
Default

Can anyone out there help me? I have a deadline approaching and not sure how to complete this action. Thanks so much!
cgustin is offline   Reply With Quote
Old 02-24-2006, 04:58 PM   #8
Cota
Super Moderator
 
Cota's Avatar
 
Join Date: Jul 2001
Location: NYC
Posts: 10,175
Default

ActionScript Code:
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 );
__________________
Color Wars™ | (kul′ər wôrs) n. - Open conflict between factions. www.theColorWars.com

cota - www.chadworkman.com | http://shavedplatypus.com
occupation: designer | flash developer | server-side developer (php, asp, mssql, mysql)
Cota is offline   Reply With Quote
Old 02-24-2006, 06:36 PM   #9
cgustin
Registered User
 
Join Date: Feb 2006
Posts: 6
Default

Wow that was quick. Thanks so much!
cgustin is offline   Reply With Quote
Old 02-24-2006, 06:36 PM   #10
falltimemusic
I'm an alright guy
 
falltimemusic's Avatar
 
Join Date: Jun 2005
Location: I live where my rump rests
Posts: 292
Default this probably deserves its own thread...

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.
falltimemusic is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Only one sound at a time! (on button press) Hibba ActionScript 2.0 2 11-27-2005 12:05 AM
Recoginizing Key Press Problem agraddy ActionScript 2.0 2 07-25-2005 06:02 PM
on press start drag, on press stop drag. how? alapimba ActionScript 1.0 (and below) 1 06-17-2005 03:23 PM
Dragable button for array of objects? Crosz ActionScript 2.0 0 01-05-2005 04:09 PM
When I press tab on a form..... G-Rard B Other Flash General Questions 4 11-15-2004 07:00 PM


All times are GMT. The time now is 04:36 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.