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




On (keypress)



Hello,

I have tried to implement on (keypress) and it just has not worked I have a button on the main timeline with the following code...

code:
on (release, keyPress "<Enter>") {
resultSet = "Loading...";
loadVariablesNum(varPath + "/asp/stu_login.asp", 0, "POST");

}
on (release, keyPress "<Enter>") {
gotoAndPlay(148);
}


When I go to test it pressing the enter key does not advance the movie.



FlashKit > Flash Help > Flash ActionScript
Posted on: 03-24-2005, 02:45 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Keypress F5, F6, Etc
How can I get the keypress event of F5, F6, etc... I know I can't do it directly with flash, but maybe Javascript... kinda lost here...

On KeyPress Help
Anyone know how I can have Flash recognize the user pressing the F4 key for the on keyPress event?

Keypress
I'm making a personal "babybanger" game for my son, to teach him the meaning of letters, numbers and shapes...here goes:

I have movies (A-B) with each 4 frames containing different pictures which start with the current letter i.e B = Ball or Baby....., each frame has a stop action.

In my main scene I have a button with this script:


on (keyPress "b") {
_root.b.swapDepths(1);
tellTarget ("b") {
play();
}
}

So when he hits the "b" key it will play the next frame of the B movie.

The problem being that the B movie keeps playing through all the frames as long as he holds down the key, I just want it to play one frame every time he hits the "b" key.....I could really use an action with :
on (keyRelease "b") instead but can't seem to find out how.

KeyPress Help Please
I am creating a piano swf and upion the press of a key I want the button the the piano look like it is in its down state. I have placed the movieclip and given it the instance name "KeyPress1" on the stage the gave it an alpha value of "0" and then placed the following script on it.

on(keyPress "q") {
KeyPress1._alpha = 100
}

And that works except that when I release he key "q" I want the movieclip instance to change back to a "0" value and therefore not be visible and furthermore I want to make sure that while the key "q" is being pressed that the alpha value stays at "100"

How can I accomplish this? Somebody please help

Thanks in advance,
Josu

Keypress
how do i detect keypress of numbers like 3. I want to put on a frame with a stop action , a movie clip turns invisible, and a action where when you press 3, that movie clip turns visible again.
thanks.

On Keypress....
Hi all, I'm new at the flashkit-forums.

I've surfed around flashkit a lot to have a look at some sources and I learned a lot of them.

I'm certainly not a flash-expert, I'm just in a learning fase. I think it is a great programming language for web applications.

I made my first game (well actually my second, but the first one isn't really worth mentionning), and I have a little problem with it. I added it to the movies--> games -section of flashkit (although it didn't get approved yet (how long does that take normally?)).

It's a typing test game I made just to get a bit the hang of actionscripting. It tracks wich key is pressed and if it is the same key as the letter apearing on the screen then the score goes up.

No some people told me that a good adition would be that the score goes down when someone presses a wrong key. I just don't see how to implement that.

Here is how I made it: I have 26 frames and in each frame there's a letter I converted to a button. That button tracks if the key is pressed of the letter wich appears on the screen. If randomly goes to another frame (with another letter)... There's a timer included wich ends the game after 30 seconds.

Here is the code I used for tracking the key:


Code:
on (keyPress "a"){
_root.score++;
gotoAndPlay(random(26)+2);
}
I tried adding the following to let the score goes down when a wrong button is pressed but it doesn't work off course:


Code:
on (keyPress !"a"){
_root.score++;
}
Anybody has any idea on how I can implement such thing?

Thanks in advance,

greets Rob

(I attached the source-code of my game)

Keypress Help
Ok im doing a project that it set up like a video game, and want to make it two players... I have all the coding for the question generator done, but how can i go about using key strokes for contestants to "buzz in" on my game? And to also keep a tally of thier score.

Thanks any help would be appreciated!

KeyPress
I would like that this function would also be executed when i press a Key, how can i do this?

Thanks for any help.

JGraca

a1.onPress = function() {
mov1(a1, 1);
gotoAndPlay(17);
};

Keypress
can someone help me with this, just tell me what to put inside the condition

if ('Alt + Shift is pressed'){
...
}

thanks

MaX_BoY

On KeyPress In An Exe?
I'm trying to have an invisible button in a flash projecter take you back to a scene on keyPress.....its not working....does it not work in an exe?

also, is it possible to use the F1 key?

any help appreciated...

Keypress Help
Here is what I want,

I want my movie to play till the end, then stop. After it stops, I want to be able to press enter, which, in turn, would send it to the next scene. I tried the following, but to no avail. Any help would be GREATLY appreciated.

--------------
stop();
on (keyPress "<Enter>") {
gotoAndPlay(Slide2, frame 1);
}

--------------

Slide2 = Scene 2

Also, I did name my frame instance on Scene 2 "frame 1". So that is not the problem. Thanks in advance

On Keypress Help
what is the code word for if they keypress one of the numbers at the top of the keyboard.

Thanks

Keypress Help
Ok, does anyone know why this doesn't work?:


Code:
_root.currentwep = "Handgun";

//make weapons changeable
if (Key.isDown(Key.SPACE)){
_root.currentwep = "Shotgun";
}


I don't understand why it wont work when in previous games ive made it has worked. Anyway, thx.

On(keypress...
Is it possible to use other then the predefined keys for this command? For instance Command I. If not is there a work around?

Thanks in advance for any help

Keypress Help
hey, i know that you can use the keypress with up,down,left,right and some other buttons,
but what is the script for normal letters, e.g. a, s, d, w

any help would be good, thanks

jason

Keypress
could anyone help me, basicaly im using this script to make a car go forward when you press the UP button.

onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
speed += 1;
}

the problem is that i would like to change it so that you press the W button instead.

can anyone help

jaosn

KeyPress
I have this code on a button in a project:

on (rollOver) {
containerA.unloadMovie();
}
on (release, keyPress "<Right>") {
trace("The Right Arrow key was pressed");
clearInterval(timer);
goToAndPlay("81start");
containerA.attachMovie("PlayStatSymbol", "PlayStatSymbolA",1);
script50.stop("50.mp3");
}

The "keyPress" part does not work. So I took this code and put it into small file (attached) and it works fine. Any idea why it won't work in my other file?

KeyPress
What is wrong with this keyPress command?

Code:
def.onEnterFrame = function(){
x4 = this._x
y4 = this._y
y5 = y4
x5 = x4
x5 += 46
y5 += 40
y4 -= 40
if ((((guy._x > x4) && (((guy._y > y4)) && ((guy._x < x5))) && (guy._y < y5)))) {
if (keyPress "1") {
def.play();
}
}
};

dont mind the part in bold its a substitute for a hitTest command.

On Keypress...
Hi,
I tried to make a page with a very little flash movie, height=1 width=1
I wanted to make it possible to press a key on a page and there will be an other page loaded. So people will be be quicker on browser through the website.

But it doesn't work, because you have to select the movie first (almost impossible when the movie is 1 by 1 px) before you can press a key. Is there a way to avoid this? I really don't want to make a movie wich you first have to select before you can use the shortkeys



the page is located here:
http://bcounter2.techroll.nl/

The flash movie will only appear when you are logged on:
username: Kaffa
password: qwerty
its located under the image with the text "jouw profiel" above it.

on the button in the movie I have:

Code:
on (keyPress "b"){
getURL("index.php?p=bewerk_profiel", "_parent")
}
on (keyPress "p"){
getURL("index.php?user=" + user, "_parent")
}
on (keyPress "u"){
getURL("index.php?p=upgrade_profiel", "_parent")
}
on (keyPress "c"){
getURL("index.php?p=casino", "_parent")
}
on (keyPress "s"){
getURL("__________allpages/shoutbox/_shoutbox_add.php?user=" + user, "shoutbox")
}
on (keyPress "r"){
getURL("JavaScript:radio_stream(220,305)")
}
on (keyPress "l"){
getURL("index.php?action=log-out&redirect=1", "_parent")
}

On(keyPress) Bug?
I had a scroller that was working perfectly using the on (keyPress "<Down">) script. Then it just stopped working. I dismantled the script and the button and re-did the whole thing, but still no success.

Is there some kind of bug at work here? Has anyone else ever experienced an event handler just dying like that?

[F8] Keypress
I have build a lot of simulations in captivate and this time it’s just not cutting it, so I have to bring it into flash for the interactivity. JOY

Here is what I’m trying to do. I want the user to have to hold down ctrl while pressing the down key to have the move play; they will probably have to do this five times. So is it possible to handle multi key presses in flash?

Thanks in advance
Drizzle

Keypress
If I want to use the arrpw keys to move an object, there seems 3 ways top do it.

1 uses on(kepress..), 1 uses getascii key amd the other uses an event handler.

What is the difference between the 3

Keypress
If I want to use the arrpw keys to move an object, there seems 3 ways top do it.

1 uses on(kepress..), 1 uses getascii key amd the other uses an event handler.

What is the difference between the 3

Keypress
Hi experts,

Is there an alternative to using 'Keypress' when detecting keyboard actions? The problem is with 'keypress' only detecting one key at a time - if one is making a game for example, with keys to detect movement and shooting, ideally you would want it to detect more than one keypress at a time so you can move and fire at the same time without one interrupting the other.

Thanks in advance,

ADE

Keypress
Hi,

I am very very new to flash but coming along alright. I was wondering if there is a simple way to know when a key has been pressed. I dont care which key it is, I just want to know a key have been pressed on the keyboard

Thanks

[CS3] Keypress
I am pretty new to flash and now I having a hard time getting any further. This a class project I am working on.

Right now the program responds to key press but I want a pause between key press to avoid just flying through the whole thing.
The FLA can be found at

http://www.geocities.com/islamicgames/kalpha1.fla

Thanks

Keypress
If I want to use the arrpw keys to move an object, there seems 3 ways top do it.

1 uses on(kepress..), 1 uses getascii key amd the other uses an event handler.

What is the difference between the 3 ?

Any Way To Allow One Keypress OR Another?
If I have four buttons that can be clicked in my scene, is there any way to allow either "1" OR "a" to control the first one, "2" OR "b" for the second, etc?

I know I can combine different mouse events:


Code:
on (release, keyPress "1") {
gotoAndPlay(2);
}
... where the comma essentially says on release OR when pressing "1".

But when I do different keyPresses:


Code:
on (release, keyPress "1", keyPress "a") {
gotoAndPlay(2);
}
to say on mouse release OR when pressing "1" OR when pressing "a"... I get a duplicate event error. I've tried using || and various other things, and none of my efforts or searches have resulted in anything.... What would the syntax be for this? Thanks!

Keypress Fun..
Hi, i`ve made a simple character and used the key listener to get him responding to the keyboard (move left, right, up down, punch and kick). But, when i press and hold a key to move him there is a delay (he moves then waits then continues to move) - can i get rid of that? Also, there is a two-frame walk-cycle and when he moves left or right i want it to play continuously - but it doesn`t, it plays only once unless i keep rehitting the move key. Is there a known issue with this or a workaround for it?

Any help is greatly appreciated always, thanks!

More Keypress Fun
I have a car symbol which is moved around the stage using the UP, DOWN, LEFT and RIGHT arrow keys. The movement is working fine, but I want the car to be correctly orientated to the direction it is moving. I have acheived this when moving up/down by changing the yscale value, but cannot achieve the same when moving left or right. My code is as follows:


Code:
onClipEvent(enterFrame) {

_global.speed = 5;

if (Key.isDown(Key.UP)) {
this._y -= _global.speed;
this._yscale = 100;
}

if (Key.isDown(Key.DOWN)) {
this._y += _global.speed;
this._yscale = -100;
}

if (Key.isDown(Key.LEFT)) {
this._x -= _global.speed;

}

if (Key.isDown(Key.RIGHT)) {
this._x += _global.speed;
}
}
Any help would be most appreciated.

KeyPress
I'm creating a presentation (like PowerPoint). I would like to have my points come in with a differnt effect one at a time when I press the down arrow and then go to the next slide when I press the right arrow. Do I need to make each point in a separate .swf file and load each file on press? But I would like to have all my points stay on screen untill I go to the next slide. Is this possible? I'm using the McTween pluging to control my effects, I don't know if you need to know that or not, but I am.

-Thanks

On KeyPress How To?
Hi,
I would like to attach a movieclip from the library when I press the keyboard key "A". (or any other key for example)

I can't get ot to work, Please help me!!

I am using it this way:

on (keyPress "<space>"){
_root.attachMovie("myMovie_mc", "newmyMovie", _root.getNextHighestDepth());}

Keypress Help
hello,

I am completely stuck, as a newby to actionscript, yet trying to undertake in my eyes an impossible task, maybe you can help!

what i want to do is this. I have designed an animated alphabet- now i want to attatch then to keys of the keyboard so when you press the letter then on the screen it pops up. Then if left idle for 15 seconds fades out to the blank screen again. So i have all these individual animated letters as movie clips, i just need to know how to script the whole thing together!

if anyone has any info or can reffer me to a good tutorial i would be forever grateful!

thanks.

Help With Keypress
On a webpage I have a .swf that has a usernamebox, a passwordbox and a submit button. How could I get it when the password box is active (instance name pass) and the enter key is hit, It will either press the submit key or it will trigger the following code:

Code:
dataOut.user = this._parent._parent.user.text;
dataOut.pass = this._parent._parent.pass.text;
dataOut.send("http://test.DOMAIN.net/login.php", "POST");

this._parent._parent.msg.setStyle("backgroundColor", 0x003399);
this._parent._parent.msg.setStyle("borderStyle", "none");
this._parent._parent.msg.setStyle("color",0xffffff);


var dataOut:LoadVars = new LoadVars();
var dataIn:LoadVars = new LoadVars();

dataIn.onLoad = function() {
if (this.login=="1") {
this._parent._parent.msg.text = 'Welcome ' + this.username + '!';
} else {
this._parent._parent.msg.text = 'Login was not successful, please try again.';
}
}}

On Keypress
Im trying to make a reproduction of the Helicopter game for one of my pals, but instead of using the mouse i would like to use the spacebar.

How would I do this?

I have about 2 lines of code and now Im stuck...

ty for all the help in the past with tutorials btw.

if someone could give me a boost up it would be really appreciated.

On(keypress....) Help
I know this isn't secure, but for my purposes it accomplishes what I need.
I have an input field with and instance name of mytext and var pass (type: input). Below it I have created a button with the following actionscript:

quote:on (press, release, keyPress "<Enter>") {
if (pass == "1556"){
gotoAndStop("main");
}else{
error_msg = "Wrong. Please try again."
}
}

The ENTER key, however, does not seem to respond.... any ideas as to why? Do I have to somehow tie the button and input field together?

Keypress Help Please
hi i have mx 2004 and would like to know how to make a keypress sctipt for example when key a is down trace ("whatever")
please help thanks
louis.

KeyPress
how add to this code keyPress "<Enter>" ?

submit.onRelease = function() {
getURL("https://bla.bla.bla", "_self", "POST");
}
stop();

regz

elefen

HELP : Keypress
Hello,

I was doing a movie with an action that when a KEY is pressed, it will load an EXTERNAL MC on an EMPTY MC.

It is much easier done in MACROMEDIA DIRECTOR because the LINGO has provided it already. Now, I'm trying to make a FLASH version but couldn't seem to find any READY MADE actionscript for this inside FLASH.

Here is what I have in mind:


on keypress
emptyMC.loadMovie("loadedMovie.swf")
end



Thanks in advance

KeyPress?
what was that function that was an alternative to if (key.isDown) or something like that?

im trying to remember what it was.. something like

Code:
mymc.KeyPress.DOWN = function (){
}
thats not it though, please help me

Keypress Help
Im trying to make it so that when you type in "quit" anywhere on the screen the game will play a new MC.
right now i have it working when you type "q" or "Q"
heres the code:

function keyTest() {
if ((Key.getAscii() == 81) || (Key.getAscii() == 113)) {
trace ("QUIT GAME");
}
}

var eventListener:Object = new Object ();
eventListener.onKeyDown = keyTest;
Key.addListener (eventListener);

Any help would be appreciated.

Thank You

More Than One Keypress....
Hi

When i run this code - flash can only initiate one of the keypresses in the list and cannot 'multitask'! Do i need to use the mutiple key detection code or is there a simpler way of doing it???? Thanks!!


Code:


on (keyPress "<Left>") {

_rotation -= 5

}
on (keyPress "<right>") {

_rotation += 5

}
on (keyPress "<Up>") {
FwdSpd = 4

var deg =(this._rotation*(math.PI/180))
this._x = this._x + FwdSpd*math.sin(deg)
this._y = this._y - FwdSpd*math.cos(deg)
}

on (keyPress "<Down>") {

FwdSpd = 4

var deg =(this._rotation*(math.PI/180))
this._x = this._x - FwdSpd*math.sin(deg)
this._y = this._y + FwdSpd*math.cos(deg)
}

Keypress
hi to all,

i have a problem
i want to make an action so when the user press a key, any key from 1 to 9 and a to z, i want to appear a different image each time. I mean: i press f for example and image1 appears, then i press e and image3 appears beside image1, not in a seperate window.
I hope my english isnt too bad for understanding.
thanks

Keypress
hi everyone!
im trying to make a fighting game and i need to know how to do basic keypressing thingos.

i've got my character with all its animations and whatnot (as a movieclip)
now i need to know how to make it attack/die whatever when a certain key is pressed.

so, yeah i need codes.

your help would greatly be appreciated.
(can you please state wether the codes go on the movieclip or a layer, or whatever. thanks.)

Keypress
on (release, keyPress "<Enter>") {
passwordenk();
}

this code doesent work, but when i change Enter to Left it works, does any one know what the problem is?

Hel With KeyPress..
Hi all. Iam from so my english is not good but i nee help.. i need script on button.. onKey press, but i need button like "escape, F12, etc.." and i cant find this on web someone help me? ( on press moviego to next frame ).. thx so much

Keypress Help Please
hi i have mx 2004 and would like to know how to make a keypress sctipt for example when key a is down trace ("whatever")
please help thanks
louis.

KeyPress
how add to this code keyPress "<Enter>" ?

submit.onRelease = function() {
getURL("https://bla.bla.bla", "_self", "POST");
}
stop();

regz

elefen

Keypress
Hello all you flashers,

I realsie that this is a really dumb question, but I am trying to get the syntax correct for a KeyPress action.

Instead of on(keypress) do this or whatever. It would read something like hello_btn.onKeypress = function() {
gotoand stop and blah de blah. Except I cannot get the syntax right for the first line of code. I can do onRelease fine with this method but not keypress. Please help

Thanks in advance

Copyright © 2005-08 www.BigResource.com, All rights reserved