Quick Question About Key Presses
Plain and Simple: Is there anyway to make it so the viewer playing the game can't hold a button down?
For Example: I'm making a game where you shoot until you run out of bullets, then just drop the gun. So when you press control, it shoots, plus takes off one from the counter.
BUT
It only works if you lightly tap control, because If you hold it down, it goes screwy..
Thanks in advanced..
KirupaForum > Flash > Flash 8 (and earlier) > Flash MX
Posted on: 08-04-2003, 08:36 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Help With Key Presses
I tried searching the board already, so please don't flame me if this topic has already been posted. I am trying to make a navigation bar for my website based etirely on key presses. "M" will take you to the main page, "L" will take you to the links page, ect. The problem is, I keep having to click on the movie again to get the key presses to work. Is there a way to make the flash file, where the person won't have to keep clicking the flash movie to get the key presses to work? My webpage will use frames so the target frame will be the "main" one. I currently have Flash MX, and if anyone could make a tut on how to do what I asked, I'd appreciate it. Thank you for your time and help.
Flipboy101
P.S.
I learned about the key press thing by reading the tutorial someone made on this website:
http://www.flashkit.com/tutorials/In...24/index.shtml
He doesn't talk about how to make it so you don't have to keep clicking on the movie to keep the key presses working.
Key Presses
Is it possible for a movie to react if, two keys are pressed at the same time?
Key Presses
Hello Flashkit. While making a flash game for a school project, I have encountered a problem.. the game involves swimming to the surface of the water by tapping the 'space' bar button, everything works nicely except for one thing: people can cheat by holding down the space bar (which allows the user to just swim straight up). I've tried several things to fix this problem none which work. I'm basicly just using the If command with key press SPACE. Then using the this._y to make the character move...Thanks for the help!
~Cory
Key Presses
does anyone know if there is an actionscript function that will only read when a key is first pressed, and not continually pressed?
this.onKeyDown = function() {
if (Key.getCode() == Key.SPACE){
red._x++;
}
}
will continue to move "red" if I hold down spacebar, but I only want it to move when the spacebar is first pressed. Key.isDown does the same thing. help?
[FL8 AS]Help: Key Presses And MCs
okay, so ive been using flash 8 for a few months and have only done animations, nothin with actionscript(know c++ but that didnt help), so this is a really easy problem i bet.
i have a character mc, let's just call him 'Jo'. in frame 1 of 'Jo' i have an mc('bounce') and in frame 2 i have a different mc('rightUp'). i want 'bounce' to play when nothing relevant is pressed(or no key is pressed) and 'rightUp' to play all the way thru once(6 frames)when the UP key is held and the 'S' key is hit(note that the clip shouldnt play again unless 'S' is released and hit again, you can however hold 'UP'). right now i have a simple actionscript that will play 'bounce' when nothin is going on, and when 'S' is hit it plays 'rightUp' as long as the key is down. i understand why this happens but i can't figure out how to make it like i described.
here's what i have but its really not what i want at all:
onClipEvent(enterFrame){
if (Key.isDown(83)){ //key code for 's'
stop();
this.gotoAndStop(2);}//goes to the 'rightUp'
else{
this.gotoAndStop(1);//otherwise plays 'bounce' which is what i want
}}
thanks in advance for any replies
EDIT: heres an example i made to show the problem, the real one doesnt fit. remember, i want the 'bounce' to play except when UP is HELD and S is PRESSED, and i want the 'rightUP' to play all the way thru once without being interupted by hitting it again.
Must Disable Key Presses
DESPARATE FOR ANSWERS!
I'm using the tell target actionscript below to trigger a movie clip. It works fine. The problem is, I need it to lock out any other key presses once the first key is pressed. Any suggestions on how to disable key presses?
Thanks in advance.
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
tellTarget ("_root.miss") {
gotoAndPlay ("missRight");
}
}
if (Key.isDown(Key.LEFT)) {
tellTarget ("_root.miss") {
gotoAndPlay ("missLeft");
}
}
}
Grabbing Key Presses
Does anyone know if it is possible to grab the ALT key when it is pressed in a .swf or .exe(projector) file. It seems to be the only one besides F10 that I can't grab.
Key Presses And Scrolling In MX
HI! I have a scene where the text scrolls up and down using mouse release on 2 buttons. this works fine. I want to add up and down key presses to this as well so the text scrolls with them as well.
I tried adding the key presses but on previewing it, the text seems to hang and get stuck between using key presses and the mouse.
If this makes any sense does anyone know how to help me?
Thanks!
Key Presses And Listeners
HI! i am using key presses for certain things to happen within my movie but for one scene I want a key press to make one thing happen and then on another scene i want the same key press to make another thing happen.
The trouble is the key press is acting as a global for the whole file. i can't seem to remove them for each scene..i've tried removing listeners but this doesn't seem to work!!
Help! Any ideas?
Combined Key Presses
When building online tutorials using Flash MX, is it possible to combine key combinations in the "isDown" method with a textfield so that the movie will advance to another scene when the user types in the correct answer?
Multiple Key Presses
How do you allow for multiple key presses at the same time?
I want to move an object up down left and right, and any two at the same time. (ex up-right) istead of up, then right
Blocking Key Presses
Hey!
Does anyone know how to stop certain keys from being active? I have some text fields and I want to make the "" key {code 220} inactive.
I have tried...
Key.removelistener(220);
I also tried using a if statement but even if I detect it how do I remove it from the text field?
onClipEvent(KeyDown){
if(Key.getCode()==220){
--> remove last keypress?
}
}
.. any suggestions?
Key Presses On Buttons
a quick poser for you all!
I know that you can assign a key press to a button:
on (keyPress "m") {
gotoAndPlay(20);
}
but is there anyway of making it so that you have have to press 2 keys at the same time to goto a certain frame?
I know this sounds barmy, but what the client wants...
thanx in advance
:OI
Timing Your Key Presses?
I'm making a game kind of like the dance mat games (you know with timing yourself with the arrows). Anyway instead of a mat I'm using the arrow keys.
My question is say the person presses the key too early, how can I stop the person from being able to press the key at the right time? So the arrow would disappear so the player couldnt keep pressing the key and get the 'good'.
If you have any code or something that might help please reply.
I hope i've explained well enough.
Keyboard Presses...
I'm working on a hangman game with keyboard functionality, where I want each key to become disabled after the first time it is pressed.
I have a movie clip on the stage, with the onClipEvent (keyDown) code. Every time a key is pressed, the variable "name" is changed to the ltr of the corresponding key. For example, if Q is pressed:
if (pressed == 81) {
name = "ltrQ"
}
Then comes the statement below, which decides what to do based on the status of that movie clip:
//if the key that was just pressed is enabled...
if(_parent.name.enabled = true) {
//carry out the keyboard function which guesses the letter
_parent.hitLetter(pressed);
//and disable that key
_parent.name.enabled = false;
//if the key is disabled, then do nothing
} else {
}
The problem is that somehow I can keep pressing the same key and it will guess the letter over and over!!! What am I doing wrong here?
Key Presses - URGENT
I was wondering if anyone knows how to capture a combination of key presses to cause and action to happen. for example, if you hit the keys "CONTROL+W", the visibility of a MC is set to false.
I know you can make things happen by just hitting one key, such a just "W", but I am looking to make things happen with a combo of keystrokes.
Please help me.
Thanks,
~N
Simultaneous Key Presses
I would like to go to a specific frame on my timeline when a combination of keys are pressed, not just when a single key is pressed.
I have this script assigned to an invisible button on a frame in my timeline.
on (keyPress "m") {
gotoAndStop (23);
}
How can I change this so that it needs 3 or more simultaneous keypresses to goto frame 23; for example, when keys z, b & m are pressed at the same time?
Problem With Key Presses
Movie Reference: key press
Movie Play: Flash Player 8.
1. SPACE BAR not enabled. LEFT key and RIGHT key are only enabled. When the LEFT key is pressed the circle moves from the center of the stage to the left by 150 pixels, returns to the center of the stage, and stops there if the LEFT key is released in between. Otherwise it again moves to the left as before.
2. When the RIGHT key is pressed the circle moves from the center of the stage to the right by 150 pixels, returns to the center of the stage, and stops there if the RIGHT key is released in between. Otherwise it again moves to the right as before.
Problem Encountered:
1. If the SPACE BAR is pressed when the circle is moving, the circle continues moving even if the LEFT/RIGHT key is released.
2a. In the above condition (SPACE BAR pressed and RIGHT key is released), if the circle is moving towards right and the LEFT key is pressed again the movie crashes necessitating the operation of alt+ctrl+delete.
2b. In the above condition (SPACE BAR pressed and LEFT key is released), if the circle is moving towards left and the RIGHT key is pressed again the movie crashes necessitating the operation of alt+ctrl+delete.
The pressing of SPACE BAR should not have any effect on the movie playing.
I request any one to please explain the reason for the strange behavior, and suggest methods for rectifying the problem. The .FLA zipped file is attached.
[F8] Bug In Recording Key Presses?
Is this something that just happens to me or does it always happen?
Start a new document and put this code in:
Code:
this.onEnterFrame = function() {
trace(Key.isDown(Key.UP));
}
Then when you run it, hold down the RIGHT, LEFT and DOWN arrows, then press UP. It traces false even though I'm pressing UP. Anyone know why this is happening? Thanks.
Some Key Presses Don't Work
I'm using Flash CS3 with actionscript 3.0
I created a game that uses the up arrow to accelerate, left and right to turn, and the spacebar to shoot, and i'm using key events to keep track of which keys are down:
Code:
var keys:Array = new Array(256);
addEventListener(KeyboardEvent.KEY_DOWN, keyPressed)
addEventListener(KeyboardEvent.KEY_UP, keyReleased)
function keyPressed(evt:KeyboardEvent)
{
keys[evt.keyCode] = true;
}
function keyReleased(evt:KeyboardEvent)
{
keys[evt.keyCode] = false;
}
all this works fine, i can test for any key on the keyboard and it works. The problem comes in when i press more than two keys at once:
if i hold the up arrow and right arrow, and then press the left arrow, it doesn't notice the left arrow
if i hold up and left, and then press right, it doesn't notice the right
now where it gets really weird is when i get space mixed in there
up arrow, right arrow, and space all down at the same time, all three work
however, if i hold up and left, and then press space, space does not work
if i hold up and space, and then press left, left does not work
I think that's probably enough examples lol i hope you understand what i mean...
oh and it does this in testing as well as when it is published and put on a website, and I also have keyboard shortcuts turned off while testing
does anyone know what is going on here and hopefully how to fix it?
Thanks, Benjamin
Some Key Presses Don't Work
I'm using Flash CS3 with actionscript 3.0
I created a game that uses the up arrow to accelerate, left and right to turn, and the spacebar to shoot, and i'm using key events to keep track of which keys are down:
Code:
var keys:Array = new Array(256);
addEventListener(KeyboardEvent.KEY_DOWN, keyPressed)
addEventListener(KeyboardEvent.KEY_UP, keyReleased)
function keyPressed(evt:KeyboardEvent)
{
keys[evt.keyCode] = true;
}
function keyReleased(evt:KeyboardEvent)
{
keys[evt.keyCode] = false;
}
all this works fine, i can test for any key on the keyboard and it works. The problem comes in when i press more than two keys at once:
if i hold the up arrow and right arrow, and then press the left arrow, it doesn't notice the left arrow
if i hold up and left, and then press right, it doesn't notice the right
now where it gets really weird is when i get space mixed in there
up arrow, right arrow, and space all down at the same time, all three work
however, if i hold up and left, and then press space, space does not work
if i hold up and space, and then press left, left does not work
I think that's probably enough examples lol i hope you understand what i mean...
oh and it does this in testing as well as when it is published and put on a website, and I also have keyboard shortcuts turned off while testing
does anyone know what is going on here and hopefully how to fix it?
Thanks, Benjamin
Handling Key Presses
Hi,
I have a main class which has a key listner added to it like this:
Code:
//Function called every key press...
_level0.onKeyDown = controlPlayer();
Key.addListener(_level0);
The function that is launched when a key is pressed looks like this:
Code:
function controlPlayer()
{
switch( Key.getCode() )
{
case Key.LEFT :
{
pPlayer.movePlayerLeft( sPlayerSpeed );
break;
}
case Key.RIGHT :
{
pPlayer.movePlayerRight( sPlayerSpeed );
break;
}
case Key.SPACE :
{
pPlayer.shootPlayer( gGunType );
break;
}
}
}
And (as an example) one of the functoins that is called when a key is pressed looks like this:
Code:
public function movePlayerLeft( inSpeed:Number )
{
if( playerShip._x <= 40 )
playerShip._x += inSpeed;
else
playerShip._x -= inSpeed;
}
However, it does not seems to work. I tried adding some debug lines to output text to the screen at various parts of my code and found the following:
- If the left, right or space keys are pressed, nothing happens (i.e. if a debug line were placed in the case Key.LEFT etc areas then it would not be printed to the screen).
- This means that the player moving functions are never reached, hence the player cannot move.
- If a debug line is placed at the start of the controlPlayer function it is fired but it is fired at the start of the program without any keys being pressed.
Anyone know what I've done wrong?
Thanks,
J
Key Presses Questions
Hello Actionscript.org forums,
To fill you in on my situation, I have created two movie clips for a character that I am trying to implement so that the user can control them - one for a walk cycle and one for a jump.
The background for the piece is already set up to move when the user presses the left or right arrows, and is also set to speed up and down with the other two arrow keys.
What I would like to do is have my character move when the user presses the arrow keys, (so the background and character move at the same time) and stops when none are pressed. I think that it may be possible to do this with a long not IF statement somehow, and to also set up a key for the jumping animation as well, when the user presses the spacebar for example.
Thanks in advance.
Key Presses Fail.
This is EXTREMELY frustrating. Key press sensing isn't working.... Here's my code:
addEventListener( Event.ENTER_FRAME, MoveComputerPaddle );
addEventListener( KeyboardEvent.KEY_UP, MovePlayerPaddleUp );
addEventListener( KeyboardEvent.KEY_DOWN, MovePlayerPaddleDown );
function MoveComputerPaddle(event:Event):void
{
// computer movement
if ( rpaddle.y > goo.y )
{
rpaddle.y += -3;
}
if ( rpaddle.y < goo.y )
{
rpaddle.y += 3;
}
}
function MovePlayerPaddleUp(event:KeyboardEvent):void
{
lpaddle.x += -3; // up
}
function MovePlayerPaddleDown(event:KeyboardEvent):void
{
lpaddle.x += 3; // down
}
Here are my errors:
NONE
/
|
WEIRD
The only thing that works is the computer paddle. No errors. What am I doing wrong? I've been trying to fix this for an hour....
Not Detecting Key Presses
Anyone have any problems with flash not detecting key presses? I have a game that has not been changed. An hour ago the key presses were being detected, now they are not. My keyboard works fine and flash is checking for the key press yet Flash is not detecting them. This is happening using the Flash player provided with CS3 and happens on other gaming websites. It will not detect any keys. I was hoping someone might have ran into this as well and I am not going insane
Edit: It seems after a hard restart i get use of the keys again. Still baffled at what could have been the problem.
Catching Key Presses
hi!
I'd like to find out the best practices on key press "catching". There are many objects in my movie clip that need to respond when certain keys are pressed. How is it better: if I create a global function that would catch the keypresses and then check which component is active and then check if the key pressed applies for that component (seems quite complicated), or rather to hard code every key-related event handler for each and every component (they are also located in many different frames)?
Isn't there an easier way?
Thanks!
Drawing By Key Presses
Good Week All
I'm trying to delve into some drawing methods, so let me rephrase a question which I posted some time ago:
Basically what I am trying to do, and failing in, is moving and object (a dot) on the stage with the keyboard arrows (simple enough) but have a line follow the object (so the keys will move the dot, and also draw a line, as if the dot is the pen).
I was playing around with different code examples, but I cannot get it to work, and I think it might be a code hierarchy thing that I am not aware of, since the drawing code will need to end up on the stage's code (main) and the keys I am using are now on the MovieClip...;
I am attaching the 2 example codes I am learning from:
Thanks for any help people!, again I am new at this.
Attach Code
//Drawing by mouse example (got me into the "lineTo"...)
createEmptyMovieClip("Draw",1);
Draw.lineStyle(2,0x000000,100);
onMouseDown = function ()
{
Draw.moveTo(_xmouse, _ymouse);
onMouseMove = function ()
{ Draw.lineTo(_xmouse, _ymouse);}
}
onMouseUp=function()
{
onMouseMove=null;
}
// End of Drawing by mouse
// Example 2 - simple ball moving around stage with boundaries
onClipEvent (load) {
// sets our variables
movement = 10;
movieWidth = 300;
movieHeight = 150;
ballRadius = this._width / 2;
}
onClipEvent (enterFrame) {
// continually looks for the edges of our ball
ballBounds = this.getBounds(_root);
//left arrow key
if (Key.isDown( 37 )) {
if (ballBounds.xMin<= 0) {
this._x = 0 + ballRadius + movement;
}
this._x = this._x - movement;
}
//right arrow key
if (Key.isDown( 39 )) {
if (ballBounds.xMax >= movieWidth) {
this._x = movieWidth - ballRadius - movement;
}
this._x = this._x + movement;
}
//up arrow key
if (Key.isDown( 38 )) {
if (ballBounds.yMin <= 0) {
this._y = 0 + ballRadius + movement;
}
this._y = this._y - movement;
}
//down arrow key
if (Key.isDown( 40 )) {
if (ballBounds.yMax >= movieHeight) {
this._y = movieHeight - ballRadius - movement;
}
this._y = this._y + movement;
}
}
Edited: 04/15/2007 at 03:57:35 PM by adamlewen
Disabling Key Presses
I was wondering if anyone can help - I am creating a dancing game:
http://www.handsomeboymodelingschool...es/dancingjoe/
I need to disable the keyboard after each key is pressed, so if the user presses the UP key untill the character has finihsed doing the move no other key can be pressed.
is this possible?
Question About Key Presses...
Hi.. I'm writing a simple pong game. it's a one frame movie, and I have a function that runs whenever the ball goes out of bounds... I want that function to hold the action until the enter key is pressed... do you guys know how I can do that?
thanks
Getting Key Presses To Fire Only Once
Hi all,
I set up some code to record key presses and specific chords. My problem is that I only want the keys to fire once when pressed. This is especially a problem when I require the user to hold CTRL + LEFT for an action.
The user experience is that I want users to hold down CTRL to enter a mode and then press the LEFT key as many times as needed. Currently, the CTRL trace and LEFT trace fire continuously. Is there a way to do a onKeyRelease?
Code:
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.CONTROL)) {
trace("control is down");
if ((Key.isDown(Key.LEFT))) {
trace("delete a key");
}
}
if (Key.isDown(Key.LEFT)) {
trace("left is down");
}
if (Key.isDown(Key.UP)) {
trace("up is down");
}
if (Key.isDown(Key.RIGHT)) {
trace("right is down");
}
if (Key.isDown(Key.DOWN)) {
trace("down is down");
}
};
keyListener.onKeyUp = function() {
}
Key.addListener(keyListener);
thanks,
nick
Return Key Presses (AS2)
I have code on my flash that allows the user to tab to certain buttons and press enter to enter it... but when ever I hit return with the keypress code it wipes the .swf file and goes blank... is this something to do with refreshing? Can anyone point out where I am going wrong.... thanks
Code:
var EscapeListener:Object = new Object();
EscapeListener.onKeyDown = function() {
if (Key.getCode() == 27) {
_root.exitP_mc._visible = false;
_root.alpha_mc._visible = false;
} else if (Key.getCode() == 13) {
root.exitP_mc._visible = false;
_root.alpha_mc._visible = false;
}
};
Key.addListener(EscapeListener);
Interrupting Key Presses
I am creating a console for my game so that i can enter commands from the console to run scripts.
When you enter text into the console and press enter, the command should run. Also the text in the console should then disappear. I have set that all up, but when i set the text property of the TextField to "" after they press enter, there is still apparently a newline in the textbox... so for some reason setting it to an empty string doesnt completely clear it. So is there a way i can do that? or how can i "interrupt" the enter key press so that i can act when it is pressed, but so that it doesnt actually get entered into the textbox?
thanks a lot!
Disabling Key Presses
I was wondering if anyone can help - I am creating a dancing game:
http://www.handsomeboymodelingschool...es/dancingjoe/
I need to disable the keyboard after each key is pressed, so if the user presses the UP key untill the character has finihsed doing the move no other key can be pressed.
is this possible?
Using AddListener For Key Presses?
Hi all,
I'm trying to control animation by a keypress. What I want is to be able to sense whether an arrow key is hit which would play one animation cycle and then play a second animation cycle when the key is let go (via frame labels). I thought this would be easy enough with addListener but I can't seem to figure out how to sense when the key is let go to trigger the second animation. Any help would be greatly appreciated.
Breakdown:
Hit (Right Arrow) --> Play (frameLabel01)
Release (Right Arrow) --> Play (frameLabel02)
Thanks!
Multiple Key Presses In Flash
Hi,
I'm making a game in Flash and a problem I'm having is that when one key is pressed and you press another, the first key has no effect anymore.
In short; does anyone know if it's possible to press two buttons on the keyboard and attach actions to them and have them executed also at the same time ?
Capturing Key Presses In Flash 4
Flash 5 makes it easy, but I am stuck with programming for Flash 4. What is the best way to capture key presses in Flash 4? I am trying to capture when user presses an Alt, Ctrl and Tab keys.
Thanks!
Scrolling Text And Key Presses
HI! Does anyone know how to make dynamic text scroll up and down using the up and down arrow keys instead of mouse clicks?
I've tried to get it to work but it gets stuck because it doesn't recognise the key being lifted up once it's been pressed down.
Thanks!
Key Presses And Changing A Textfield
I have a symbol with an animation in it. At a certain frame I want it so that if the left arrow button is pressed, a text box on the stage increases by one. But the problem is, is if left isn't pressed, I need the textbox to goto 0. The main problem is that the only way to check to see if it is pressed, that I know of, is to have it in an if statement. But the way it is set up is that if I put the code on a keyframe with say 10 frames after that and then another keyframe, you would have to hold left for the whole 11 frames of it. And when I put the code on each of the frames (same code 11 times) it will add the text field too many times. So I you either hold down left for too long or not long enough. Any help is appreciated
Thanx
On Keypress Not Detecting Key Presses
I am having a problem on a form in flash. I have code setup to handle tab from field to field. The problem is that when I press the tab key, the on keypress "<Tab>" function does not kick off.
I have the code in a hidden button. Its only purpose is to detect the tab key press, and determine which field on the form the focus should go to.
I tried putting other key traps in there ofr Enter and Page up and they were not being trapped either.
Is there anything special I need to do to make the key presses get detected?
I Need Key Presses To Activate Buttons. Help
In the past, I've successfully had button actions activated by keystrokes by placing the "on (keyPress "a")"-style actions on the appropriate button instances.
I've weaned myself away from attaching code to the buttons -- how can I do the same type of thing from the main timeline? I have A-Z buttons that work fine . . . now I need to have the A-Z button actions work when the keys A-Z are pressed.
Oh, and once a button is pressed, it has to disappear (this currently works when you click on each button), and the corresponding key disabled.
Can anyone help?? Please?? Thanks.
Flash 5 Keyboard Presses Help
I know how to do key presses for the arrow keys:
if (Key.isDown(KEY.UP))
But i was wondering how to do it with the letter keys. Like, i want to move my character using the WASD keys. What's the script for that? Thanks in advance.
How Move A Character With Key Presses?
I am trying to setup a simple character so that when left, right etc keys are pressed he moves left, right..ect..
But I also want to move the time line so that when he walks left a movie plays of his legs walking, facing left. When hewalks right another movie plays of his walking right.
My basic setup is here:
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_x -= speed;
this.gotoAndStop("left");
//Key.addListener(keyListener);
}
if (Key.isDown(Key.RIGHT)) {
_x += speed;
this.gotoAndStop("right");
}
}
My problem is that when I release the left or right key the guys legs keep going. How can I sense that the key is released and move the movie back to the relevant frame?
Cheers
NEil
Counting The Number Of Key Presses
Hello All,
I'm building a presentation type of movie.
All navigation is handled by the left and right key commands.
On some "slides" in the presentation, different things are supposed to happen depending on the number of times the user clicks the right arrow.
e.g. show one of several movies, advance to the next frame label, etc.
Below is the code I came up with but it's not elegant and it doesn't always work - sometimes it does. I'm sure I'm just too burned out to see something obvious.
Can someone please suggest how to do this?
Thanks,
paris
count=0;
blank_mc1.onEnterFrame=function() {
if ((Key.isDown(Key.RIGHT)) || (Key.isDown(Key.SPACE))) {
count++;
trace(count);
if (count==1) {
trace("count1");
attachMovie("expConsumerEd","newConsumerEd",1);
newConsumerEd._x=500;
newConsumerEd._y=150;
} else if (count ==2) {
trace("count2");
attachMovie("expIncentives","newIncentives",2);
newIncentives._x=500;
newIncentives._y=300;
} else if (count==3) {
trace("count3")
attachMovie("expHighlyEff","newHighlyEff",3);
newHighlyEff._x=500;
newHighlyEff._y=350;
} else if (count==4) {
trace("count4");
attachMovie("expLegislation","newLegislation",4);
newLegislation._x=500;
newLegislation._y=500;
} else if (count==5) {
trace("count5");
attachMovie("expConsumerCust","newConsumerCust",5) ;
newConsumerCust._x=500;
newConsumerCust._y=550;
} else if(count==6) {
trace("count6");
gotoAndPlay("slide14");
}
}
if (Key.isDown(Key.LEFT)) {
gotoAndPlay("slide12");
}
}
[F8] Firefox Browser Not Getting Key Presses
Trying to get Capoeira Fighter 3 working for Firefox.
http://www.shockwave.com/gamelanding/capfighter3.jsp
Currently it will not read key Presses although mouse clicks work fine. Internet Explorer works like a charm.
Any one know what causes this?
[F8] Storing And Activating Key Presses
Hi there, I'm still fairly new to flash. I am currently trying to figure out how to use Flash to store Key Presses. I have read all about calling the Object KeyListener but I really don't understand how it works or how to use it. I'll try to explain as best I can. What I would like to achieve is:
- Have my user press the left or right arrow keys between frames 10 and 40
- Have my program store this
- In frame 50 whichever arrow was pressed will activate a go to frame code i.e. if left was pressed they will jump to frame 60, if right was pressed they will jump to frame 70.
I hope this makes some sense to somebody.
Multiple Key Presses Problem HELP
Hi I can't figure out why there is a delay in the user moving and why it can't sense more then one keypress at a given time could one of you tell me how to fix this?
PHP Code:
///Speed Variables
var speed_x:Number = 0;
var speed_y:Number = 0;
///Acc Variables
var acc_x:Number = 0.8;
var acc_y:Number = 0.8;
///Dec Variables
var dec_x:Number = 0.95;
var dec_y:Number = 0.95;
//Stage Code
var sw_min:Number = stage.width * -1;
var sw_max:Number = stage.width;
var sh_min:Number = stage.height * -1;
var sh_max:Number = stage.height;
//User Code
user.addEventListener(Event.ENTER_FRAME, userRun);
function userRun(event:Event):void {
///Move Player
user.x += speed_x;
user.y += speed_y;
speed_y *= dec_y;
speed_x *= dec_x;
}
//Key Presses
stage.addEventListener(KeyboardEvent.KEY_DOWN, KEY_DOWN);
stage.addEventListener(KeyboardEvent.KEY_DOWN, KEY_UP);
stage.addEventListener(KeyboardEvent.KEY_DOWN, KEY_LEFT);
stage.addEventListener(KeyboardEvent.KEY_DOWN, KEY_RIGHT);
function KEY_LEFT (evt:KeyboardEvent):void {
if(evt.keyCode == 37){
speed_x -= acc_x;
}
}
function KEY_UP (evt:KeyboardEvent):void {
if(evt.keyCode == 38){
speed_y -= acc_y;
}
}
function KEY_RIGHT (evt:KeyboardEvent):void {
if(evt.keyCode == 39){
speed_x += acc_x;
}
}
function KEY_DOWN (evt:KeyboardEvent):void {
if(evt.keyCode == 40){
speed_y += acc_y;
}
}
[F8] Detecting Button Presses
Is there a way to detect if specific buttons have been pressed? I need to create something where if a couple specific buttons have not been pressed within a cretin amount of time then it will redirect you to another page. Does anyone know if this can be done?
|