Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

On Key Press troubles

Posted on 2006-05-09
14
Medium Priority
?
350 Views
Last Modified: 2012-06-27
I need a function in ActionScript that will allow me to press enter and make an instance of an object visible. This will not be attached to a movie clip or a button instance, as Macromedia seems to require. How do I do this?
0
Comment
Question by:Ten90Group
  • 8
  • 3
  • 3
14 Comments
 
LVL 17

Expert Comment

by:Dushan De Silva
ID: 16644554
on(keyPress "<enter>"){
instance1.visible= true;
}


BR Dushan
0
 

Author Comment

by:Ten90Group
ID: 16644609
That returns the following error upon debugging:


Mouse events are permitted only for button instances on(keyPress "<Enter>"){
0
 
LVL 17

Expert Comment

by:Dushan De Silva
ID: 16644631
Create a button. And put action script on it. Then hide it. (Alpha=0, or Visible=false..)

BR Dushan
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Ten90Group
ID: 16644668
This does not work. I hit enter, and nothing happens.
0
 

Author Comment

by:Ten90Group
ID: 16644679
If this would work better for you, may I have your AIM or Yahoo screen name? I need this resolved ASAP for a client. Thanks.
0
 

Author Comment

by:Ten90Group
ID: 16644717
OK, here is my issue now. It seems that this function works for every key EXCEPT enter. I have tried typing <Enter>, <enter>, and <ENTER> and none work. Is there maybe a disabled setting somewhere?
0
 
LVL 2

Accepted Solution

by:
oddhours earned 2000 total points
ID: 16644752
try this (courtesy of http://www.actionscript4designers.com/wmg3/input_text_enter_key.html):

/*** listening for the Enter/Return key ***/
keyListener = new Object();       // establish listener (generic) object

keyListener.onKeyUp = function () {        // when keyboard key released
    // take action
                                     // display code of last key pressed
    code_txt.text = Key.getCode().toString();
                                      // if Enter/Return key was pressed
    if (Key.getCode() == Key.ENTER) {        trace("ENTER key pressed");    }
}
 
Key.addListener(keyListener);      // register object to receive onKeyUp
0
 

Author Comment

by:Ten90Group
ID: 16644775
This does not work, oddhours. It is as if Flash does not like the enter key at all.
0
 

Author Comment

by:Ten90Group
ID: 16644780
This did work for other keys, such as the LEFT key.
0
 
LVL 2

Expert Comment

by:oddhours
ID: 16644783
you can replace the code:
trace("ENTER key pressed");    

with whatever you like for example:

instanceNameToShow_mc._visible = true;
0
 
LVL 17

Expert Comment

by:Dushan De Silva
ID: 16644788
my messenger ID is same in my profile's email address. But now I'm in home. I will at office after one hour.

BR Dushan
0
 

Author Comment

by:Ten90Group
ID: 16644811
OK, heres the deal.
I tried oddhours' method, and it did not work. I then started searching for settings which would enable the enter key. I found a setting in the Publish Preview window called Disable Keyboard Shortcuts, located under Control. When this option is checked, the Enter key works. Only problem is now how do I make sure that this setting is included in the Publish settings?
0
 

Author Comment

by:Ten90Group
ID: 16644828
Woo hoo! Problem fixed! Thanks everyone for your help!
0
 
LVL 2

Expert Comment

by:oddhours
ID: 16644836
Congrats!
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question