Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-22-2003, 01:26 PM   #1
Gerebeto
Registered User
 
Join Date: Sep 2002
Location: Lisbon
Posts: 309
Send a message via ICQ to Gerebeto
Exclamation Pressed Key Detect

Hello,

i have a menu with 3 options: "1", "2", "3".

i want to detect when key 1, 2 or 3 is pressed. When it's pressed i want variable Answer to be equal to the pressed key. If another key is pressed so it will keep waiting for a valid answer.

Thanks,
Miguel
Gerebeto is offline   Reply With Quote
Old 06-22-2003, 01:42 PM   #2
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

ActionScript Code:
_root.onEnterFrame = function(){     if(Key.isDown(49)){         trace("1")         }     }
2 = 50
3 = 51
__________________
‚€* GOD Is Near ‚€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
farafiro is offline   Reply With Quote
Old 06-22-2003, 02:02 PM   #3
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,875
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

this might be of use too.

http://proto.layer51.com/d.aspx?f=838
__________________
(6)
senocular is offline   Reply With Quote
Old 06-26-2003, 01:27 PM   #4
Gerebeto
Registered User
 
Join Date: Sep 2002
Location: Lisbon
Posts: 309
Send a message via ICQ to Gerebeto
Exclamation Can u help me out? 2 Senocular and everybody else

Hello,

i used the code on http://proto.layer51.com/d.aspx?f=838 but i have some problems.
I placed this on main timeline in Actions Layer:


Key.addListener(Key);
Key.onKeyDown = function(){
var dwn = String.fromCharCode(this.getAscii());
if (dwn.length) this.broadcastMessage("onKey"+dwn+"Down");
}


There were to places where i wanted to check is a key is pressed: in MC1 and MC2 both placed in main timeline.

So in MC1 i placed this code in Actions layer:

Key.addListener(this);
this.onKey1Down = function(){
_root.MC2.gotoAndPlay("start");
}


And in MC2 i placed the following code:

Key.addListener(this);
this.onKey1Down = function(){
_root.MCFast._alpha=100;
}


What seems to happen is that when flash is in MC2, and i press 1 both actions take place:
_root.MC2.gotoAndPlay("start"); and
_root.MCFast._alpha=100;

Can u tell me what is going wrong? I also tryied to understand the code but i am having some problems in doing it.

Thanks,
Miguel
Gerebeto is offline   Reply With Quote
Old 06-26-2003, 06:23 PM   #5
Gerebeto
Registered User
 
Join Date: Sep 2002
Location: Lisbon
Posts: 309
Send a message via ICQ to Gerebeto
Default How can i do that?

Hello,

i was in Ultrashock web site reading about it but i am a little bit lost. Senocular, what kind of changes do i need to make so i can make this work...

Basicly what i want is to check if the user pressed a certain key, but i want to use it in several places of my Movie, and to run certain actions when a certain key is pressed.

Thank You for your help,
Miguel
Gerebeto is offline   Reply With Quote
Old 06-26-2003, 06:35 PM   #6
Gerebeto
Registered User
 
Join Date: Sep 2002
Location: Lisbon
Posts: 309
Send a message via ICQ to Gerebeto
Question How can i do that?

How can i do that?
Hello,

i was in Ultrashock web site reading about it but i am a little bit lost. Senocular, what kind of changes do i need to make so i can make this work...

Basicly what i want is to check if the user pressed a certain key, but i want to use it in several places of my Movie, and to run certain actions when a certain key is pressed.

Thank You for your help,
Miguel
Gerebeto is offline   Reply With Quote
Old 06-26-2003, 06:41 PM   #7
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

if u r gonna use the broadcastMessage(), u should read all about the undocumented code
see it in the tuts here
www.ultrashock.com
__________________
‚€* GOD Is Near ‚€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
farafiro is offline   Reply With Quote
Old 06-27-2003, 02:38 AM   #8
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,875
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

yes, both actions take place because you defined them for both clips... why wouldnt they both take place? If you dont want them to both take place then you need to set things up a little differently to behave the way you want them to.
__________________
(6)
senocular 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 Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:23 PM.

///
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.