Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








Adding Keys Other Than The Default Keys


Say you want to make a 2-player Flash game (I don’t quite know how yet but I’m getting there). I have noticed that the selection of keys is limited to only a few keys (The arrow keys are there, and so are keys like Shift and Caps Lock, but there are many missing). I have played Flash games that had a second player using the A,S,D, and W keys for movement as well as the arrow keys. My only guess on how to get these keys is with one of the following incomplete codes:

if(Key.isDown(Key.getAscii()))

if(Key.isDown(Key.addListener()))

if(Key.isDown(Key.getCode()))

if(Key.isDown(Key.removeListener())

Hey, please correct me on this if what I want to do has nothing to do with these. They’re my only guess. If one of these pieces of code will go in the direction that I want, please tell me how. Thanks!




ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 06-17-2006, 04:25 AM


View Complete Forum Thread with Replies

Sponsored Links:

How To Turn Off Default Keys (ENTER, TAB...)?
How can I turn off the default shotcut keys that control the movie like: ENTER(plays the next frame) or TAB (jumps from button to button)?

I simply want to get rid of the Yellow boxes surrounding the button when the TAB key is pressed.

View Replies !    View Related
Code Needed For Shortcut Keys (access Keys) For Flash CS3
I have been looking for quite awhile for the code to allow the user to, for example, press ALT+I or CTRL+I in order to navigate on the installer screen for a CD. I started out with dynamic text boxes and then created invisible buttons behind that in order to get tabs to work. I am new at this so the little reference I found online or in Flash help lost me. Does anyone know what code is needed to get this to work--creating access keys in Flash 9?

Thanks for any help.

View Replies !    View Related
Adding Arrow Keys Control
I've been trying to work out how to get this script to work with mouseMove AND Key.isDown control:

Code:
onClipEvent(load){

scrollIN = _root.range._y-_root.range._height
scrollOUT = _root.range._y

lowestScale = 180
highestScale = 12000

_y = scrollIN + (scrollOUT - scrollIN)/1

scaleFactor = Math.pow(highestScale/lowestScale,1/(scrollOUT-scrollIN))
function SetScale(){
_root.scale = _root.map._xscale = _root.map._yscale = lowestScale * Math.pow(scaleFactor,(scrollOUT-_y))
}
SetScale()
}
onClipEvent(mouseMove){
if (dragging){
_y = Math.min(Math.max(_parent._ymouse,scrollIN),scrollOUT)
SetScale()
updateAfterEvent();
}
}
The mouseMove is working fine on my slider, but I am having no luck getting it to work with Arrow Keys.
I've been trying something like this:

Code:
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
this._ymouse -= scrollIN;
}
if (Key.isDown(Key.RIGHT)) {
this._ymouse += scrollOUT;
}
}
As you can see, I have it all wrong.
Any mathematicians or actionScripters able to point me on the right path?

Thanks.

Note
I'm trying to get this to be Flash5 compatible, but it isn't mandatory.

View Replies !    View Related
Tab Keys And Access Keys
I filled in the required info for dynamic textboxes in the accessibility panel but the tab keys still do not work in the exe file. Flash CS3.

Any clues?

Thanks.

View Replies !    View Related
HELP WITH KEYS (keyboard Keys)...
Hey, thanks for reading.
I need to be able to disable the keys used on Macs and PCs that exit or quit the player, so that the only way to close the player is to use the quit button.

The SWF will be played using the stand-alone player, not using a web page.


Incase you are not sure of which keys are the "exit keys",

on PCs it is 'Alt + F4'
on Macs it is 'Apple + Q', or 'command + Q'

on macs, the command key is the proper name, and apple key is the common name. If possible, when they (the user) press the apple or Alt key in any combination with any other key, nothing should happen, so that the player (in fullscreen) does not quit. As long as the player does not quit, any solution is a good solution.

Thanks, from Matt


PS: contact me using the following email address:
sugar_addict_500@hotmail.com

View Replies !    View Related
Keys.
Yeah, so how does everyody do that stuff where when you press a key on the keyboard it does something?

Well, that didn't come out as intelligent sounding as I wanted it to. But anyways, all I can do is Flash stuff with your mouse. How do you do the coding to use your keyboard?

Looking throught Macromedia's Actionscript I see stuff like Key.SPACE and Key.BACKSPACE

Is this how it's done?

And also how do games with 2D characters graphics move left and right by pressing the arrow keys? I'm not making a game involving this I'm just wondering. But I would like to learn how to use key functions. Any help?

View Replies !    View Related
KEYS
Ive done some stuff using IF Key.isDown... and would like to know if there's a way to make this: "If Key.DOWN is pressed AND key.UP is pressed too at the same time then..."
Can u help me?
Thanks a lot

View Replies !    View Related
If No Keys Are Down
how do i detect if no keys are being pressed, is that possible?

View Replies !    View Related
Keys
Hello, I am trying to set up a text field with an integrated bullet system in. This is the code I am using and it sort of all works fine.

----
myListener = new Object();
myListener.onKeyDown = function() {
my_fmt = new TextFormat();
my_fmt.bullet = true;
my_fmt.italic = true;
if (Key.isDown(Key.SHIFT)) {
indenter = indenter+30;
my_fmt.blockIndent = indenter;
}
if (Key.isDown(Key.CONTROL)) {
indenter = indenter-30;
my_fmt.blockIndent = indenter;
}
mybox.setNewTextFormat(my_fmt);

};
Key.addListener(myListener);

----

But obviously using the Shift and Control key for controlling indents and bullets isn't really effective. I want to be able to use the TAB button to indent and SHIFT and TAB to go back from the indent, just like any microsoft application.
I have tried a few things but can't get anything to work, with the tab button just selecting everything each time.

some help on this would be great.

Thanks.
Kaan.

View Replies !    View Related
F Keys
Is there a way to place a button in my flash movie so when it is pushed it is equal to pushing F5 (refresh page)?
I don't want to put an absolute path in the html page if I can help it. Can I just have it refresh the current page as the F5 button does?
Also, where can I find a list of the key codes?
Thanks

View Replies !    View Related
Keys
Hey, what do u use to tell when no keys are pressed? Because nothing i try works...:'(

View Replies !    View Related
Keys
This is a pretty basic question, but how can you get flash to detect other keys via. ascii? And when your holding that key down, etc.

View Replies !    View Related
Looking For Anything With Keys
Does anyone know where i can find FX's of keys. All kinds... Keys turning locks, movies of keys. please let me know if you find anything with Keys. New keys Skeleton keys, gold keys, Keys, Keys, Keys. These will be used on my web site.

Thanks,
Benny Sax

View Replies !    View Related
[F8] Other Keys
Hello. I'm making a game. On the MC I have this script:

onClipEvent (keyUp) {
if (Key.getCode() == 90) {
gotoAndPlay(4);
}
}

I want it to go to frame 4 of my MC which shows him punching when you press Z. But that does not work.

So for my question:

Why is this not working? Could someone please help?

And is 90 the right code for the Z key?

Thanks,

--DC

View Replies !    View Related
Several Keys
I'm trying to do a game that you have to hold down at least 10 keys at the same time. But after I have pressed down 3-4 keys the 5'th key dosent work. Flash cant get that input until I have relesed the other keys.

Need Help!!!

View Replies !    View Related
Using The F1 Keys?
Is it possible to trigger the F1 - F12 keys in flash? I can't seem to find it listed in the reference manual I'm using.

Cheers for any help!

View Replies !    View Related
[F8] Map Keys.
I've seen several online games that allow the user to input their own keys in the option menu. I was wondering if someone could show me a step by step tutorial. I know I would have to use the var in the script, for example:

onEnterFrame = function() {
if (Key.isDown(upkey)) {
mcUse._y -= 5;
}
}

But what I'm stuck on is executing the Key.getCode() by clicking on the MC in the stage, such as clicking the up MC to set the new up key, also I need the MC to say via image "Click Any Key", as well I need it to say the key you selected in a text box, and last I need to figure out how to set defaults.

What I was thinking of doing is using getASCII and somehow telling it put it in a dynamic text box on the first frame of the adjacent MC. Then when the MC is clicked on, it should go to frame two and say "Hit Any Key".

View Replies !    View Related
Keys Down
Code:
function myOnPress() {
trace("hello");
}
function myOnKeyDown() {
// 55 is key code của fím 7
if (Key.isDown(Key.CONTROL) && Key.getCode() == 55) {
Selection.setFocus(my_btn);
my_btn.onPress();
}
}
var myListener:Object = new Object();
myListener.onKeyDown = myOnKeyDown;
Key.addListener(myListener);
my_btn.onPress = myOnPress;
my_btn._accProps.shortcut = "Ctrl+7";
Accessibility.updateProperties();
When the Key is Number "if (Key.isDown(Key.CONTROL) && Key.getCode() == 55)" does, but when the Key is "a","b","c".... "if (Key.isDown(Key.CONTROL) && Key.getCode() == 55)" not work. Please help me to solve this problem. Thanks.

// I'm not good in English

View Replies !    View Related
Cannot Use Keys
When running a simple program that prints the keycode of the key pressed, only the Arrow Keys and other non-reserved by Flash keys work. The letter keys just act as their hotkeys to certain tools.

View Replies !    View Related
Other Keys
Hello. I'm making a game. On the MC I have this script:

onClipEvent (keyUp) {
if (Key.getCode() == 90) {
gotoAndPlay(4);
}
}

I want it to go to frame 4 of my MC which shows him punching when you press Z. But that does not work.

So for my question:

Why is this not working? Could someone please help?

And is 90 the right code for the Z key?

Thanks,

--DC

View Replies !    View Related
Using The W,S,A,D Keys
I'm fairly new to flash, and I have been trying to control a movie clip with the W,S,A,D keys instead of the arrows. Any help would be appreciated.

View Replies !    View Related
Help With Keys
ok, new prob, I figured that it'd be easier to make a movie clip, and inside the movie clip have frames, each frame has a diff movie clip, frame on is a guy facing forward, frame 2 is the guy faceins left, and so on. In frame 5 the guy is walking forward, in 6, walking to the left, and so on. Now, here's what I would like to accomplish (I've tried MANY things, not successful) I want to, when I push up on the keyboard, for the movie clip to go to frame 5 and stop, when I release, go to frame 1 and stop. When I push left, go to frame 6 in the movie clip and when I release go to frame 2. sounds simple right? Maybe mesa jus' dumb

View Replies !    View Related
[AS2] Map Keys.
I've seen several online games that allow the user to input their own keys in the option menu. I was wondering if someone could show me a step by step tutorial. I know I would have to use the var in the script, for example:

onEnterFrame = function() {
if (Key.isDown(upkey)) {
mcUse._y -= 5;
}
}

But what I'm stuck on is executing the Key.getCode() by clicking on the MC in the stage, such as clicking the up MC to set the new up key, also I need the MC to say via image "Click Any Key", as well I need it to say the key you selected in a text box, and last I need to figure out how to set defaults.

What I was thinking of doing is using getASCII and somehow telling it put it in a dynamic text box on the first frame of the adjacent MC. Then when the MC is clicked on, it should go to frame two and say "Hit Any Key".

View Replies !    View Related
Using Keys
I'm wondering how I can tell whether or not an alpha or numeric key is released. What kind of listener should I set up?

View Replies !    View Related
Trapping Keys
I am writing a small text editor in flash 5 and want to catch the std control keys ie. control-i to make something italic etc. however internet explorer uses this to bring up the favourites window on the left of my browser even though I have opened up the browser with no menu's of any kind so

HOW DO I STOP IT ........HELP

View Replies !    View Related
Function Keys
I am trying to get my movie to go from frame 2 to frame 3 when the user presses F4. I tried using normal mode to complete the ActionScript:

on (keyPress "") {
gotoAndStop (3);
}

but it won't add F4 for me. My Macromedia ActionScript reference guide tells me that I can use the key code 115 to represent F4, but when I go in to Expert mode and change the ActionScript to:

on (keyPress "115") {
gotoAndStop (3);
}

I get an error message saying I've entered an invalid key code. Please help!

View Replies !    View Related
Disable Certain Keys...?
I want to know how I can disable: F4, CTRL, ALT, DELETE Right/Left Mouse Click, and TAB. I use FSCOMMAND to disable "all keys" but it doesnt disable those keys... If you know how to disable those keys please tell me...

-Thanks

View Replies !    View Related
Mac/PC Universal Keys - Help
What keys that DON'T print out a character are common to most all Mac and PC platforms?

Tab.

Control.

Escape.

What else? Are the function keys pretty much universal?

I'm using this type of structure: Key.getCode() == Key.CONTROL

View Replies !    View Related
Pressing Keys
I have a basic question (I hope)- I would like to be able to push Ctrl+Shift+LeftClick on a button to have it perform an action like opening a new window- How do I go about doing this?

For the picture I would like this action to work on, it would be prefferable to not have the mouse pointer turn into the hand for buttons- is there also a way around this?

(this is for like a secret link)

View Replies !    View Related
Pressing Keys
I have a basic question (I hope)- I would like to be able to push Ctrl+Shift+LeftClick on a button to have it perform an action like opening a new window- How do I go about doing this?

For the picture I would like this action to work on, it would be prefferable to not have the mouse pointer turn into the hand for buttons- is there also a way around this?

(this is for like a secret link)

View Replies !    View Related
I`ve Lost My Keys
Hi all,

I was wondering how i can show a MC when a certain key is pressed ?
The first frame is blank, and already on the stage.
How do i call it to be visable?
Something like :

onClipEvent (enterFrame) {
if ((key.isdown(65)) {
_root.mcname(2)
}

Could someone help me with this ?

Thanks in advance !

Sidney

View Replies !    View Related
Arrow Keys?
Could someone tell me how to move an object around on the screen with the arrow keys. A step by step would me much appreciated.

and could someone tell me how to use the keyboard keys for buttons

View Replies !    View Related
Special Keys
Are there certain keys not supposed to be used in the key even handlers?? I found TAB and ENTER dont work...do they have to be handled a little differently?

View Replies !    View Related
Press 2 Keys
Is it possible to detect the pressing of 2 keys simulatneously. Like Ctrl "Z" for undoing something?

View Replies !    View Related
Function Keys (ie:F8, F9, F10)
Is there anyway that I can make a Flash projector do something when one of the Function Keys on the keyboard is pressed. For Example, When I press F10, I want a password dialog box to come up.

View Replies !    View Related
Diabling Keys?
How would i go about diabling SHIFT whilst a movieclip say mc.bullet is on the _root timeline?

View Replies !    View Related
Trap All Keys
Okay I was reading the macromedia help file. And is says if I send the fscommand:

Code:
fscommand("trapallkeys",true);
trapallkeys:
true or false:
Specifying true sends all key events, including accelerator keys, to the onClipEvent(keyDown/keyUp) handler in the Flash Player.
This is what it is suppose to do. But when I open the projector file and press the ALT key or F10 key it goes to select menu items. Has anyone every gotten this to work? Or if you have time could you also play with it to see if you can get it to work. ALT and F10 are the only keys I can't capture with Key.getCode(); Thanks for your time.

View Replies !    View Related
Disable Keys
Does anyone know how to disable a key in Flash? If I am at a specific frame, and press the key "enter", the movie jumps to the next frame. I do not want this to happen...

I tried to use this code on a invisible button to disable the key:

on (keyPress "<Enter>") {
gotoAndStop("");
}

Something like that has worked before, but does not work for me anymore (or I've got the syntax wrong).
Has anyone a clue what could fix this problem?

Thanks in advance!

View Replies !    View Related
Move MC With Keys
I want the MC to move when pressing left or right...

So far i have "on key press <left> tell target

and then what???

View Replies !    View Related
Keys Not Found
Hi there,
I've just switched from pc to mac.

But i have a small question though :
I'm currently using a Powerbook G4 and
a can't seem to find some essential
keys. I just can't find the [ and ], { and }.
I really need them to do some AS in flash.

If somebody can give me a hand with this, it would be great.
I feel so stupid.

Thanks in advance,

View Replies !    View Related
Disabling Keys
In my game, when the user presses the down button, the character moves down, even though I have nothing coded for the down button. So I don't want the user to be able to hit the down key in my game. How would I do that? Thanks

View Replies !    View Related
Problem With Keys
Hi, i have this problem. I'm making a game and the character does something when you press a certain key, but there are only Key.LEFT and Key.RIGHT and those as examples. What if you want to use letter keys? What do you write then? My code for the character is something like this:

if (Key.isDown(Key.UP)) {
*SOMETHING*
}

so what should i type if i want these keys:

E, D, S, F, W, R

i need those ones or even better, a list of all of them in case i need others. Thanks.

View Replies !    View Related
LOCKS AND KEYS Hmm
Hi guys,
I need to create a lock and a key element and the key is hanging and can be picked up and put into the lock and turned if possible,
thanks everyone,
tom

View Replies !    View Related
Lock And Keys Take 2
hi everyone,
I am trying to get a key and lock thing happening, "key2.fla" is the file I am talking about...when the key is turned I want it to go the the next scene..but it doesn't seem to work, would there be any reason for this??
thanks,
tom

View Replies !    View Related
Trap Keys
I'm trying to get trap keys to work in an executeable. Does anyone have the code or FS Command? The goal is to turn off the keyboard; or more specifically the Ctrl F function. -thanks

View Replies !    View Related
Wildcard For All Keys?
Is there a way to make a function run whenever any keys is pressed?
or is there a wildcard for all keys like
On Keypress( ? )

View Replies !    View Related
Numbers For Keys
okay im making like a decoder thing in MX using this kinda code:
} else if (Key.isDown(68)) {
_root.txt += "f";
but i dont know all the numbers for the keys a-z can anybody tell me where i can find out? plus, is it possible to use " " as a space?

View Replies !    View Related
Buttons Up And Down Keys
I have about 3 or 4 buttons on a menu of a game of mine and I want to start off on the top button which is highlighted then the other 3 or 2 buttons are transparent then when I key up or down on the arrow keys the one button that I am on is highlighted get what I mean
Thanks for any Help

View Replies !    View Related
Problem With Keys
If you have a guy and somthing has to happen when you press the right arrow key you just need to use this script:

onClipEvent (enterFrame) {
if (key.isDown(key.RIGHT)) {
//thing that has to happen
}
}

But what script do I need when I want that thing to happen when i press the "R" butten? I tryed replacing RIGHT with R but it doesn't work.

Help me please.

View Replies !    View Related
Shortcut Keys Available ?
I would like to know whether there are any shortcut keys for the flash player menu items?
If not, is it possible to create some ?

E.G. view the attached menu.


Thanks

MM

View Replies !    View Related
Navigation Keys [HELP]
Hello,
I have a small actionscript mistake

I have made a two minute long flash movie.
I want to be able to move forward and back through it, stopping and restarting at predefined intervals.
I have created a "Marker Layer" which has keyframes at the interval points. Each keyframe in this layer is labled chapter1, chapter2 chapter3 etc.

I have written the following code in another new layer.

[code]
chapterCount = 1;
keyListener = new Object();
keyListener.onKeyDown=function(){
if (Key.getCode()==Key.RIGHT){
gotoAndPlay ("chapter"+chapterCount);
chapterCount += 1;
trace ("chapterCount"+(chapterCount));
}
else if (Key.getCode()==Key.LEFT){
gotoAndPlay ("chapter"+chapterCount);
chapterCount -= 1;
trace ("chapterCount"+(chapterCount));
}
}
Key.addListener(keyListener);
[code]

I would expect to get the following trace if I pressed the Right keyboard key 4 times.

chapterCount2
chapterCount3
chapterCount4
chapterCount5

Instead I get this:

chapterCount2
chapterCount2
chapterCount3
chapterCount2
chapterCount3
chapterCount4
chapterCount2
chapterCount3
chapterCount4
chapterCount5


Can anyone please see what I have done wrong?
Thank you much.

Tim.

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved