ActionScript 2.0 :: Key.isDown Trigger If Statement Only Once

Oct 5, 2006

I'm trying to add arrow key control to my image gallery to increment and decrement the image number, but if I go to another section and go back to the gallery, the incrementing is doubled, so that I step through the images by two's. If I repeat this, it always adds 1. Here's the code I have for the Arrow keys:

[Code]...

View 2 Replies


Similar Posts:


Actionscript 3.0 :: Alternative To Key.isDown Conditional Statement?

Oct 19, 2010

I have a logic-sorta question about finding an alternative to an if/else statement that controls key.isDown detection.(NOTE: I am using senocular's KeyObject class, the utility found on his website senocular.com, that returns key.IsDown functionality to AS3)

typically in most game/character movement tutorials I see this:

Code: Select allif (key.isDown(Keyboard.RIGHT))
moveRight();
else if (key.isDown(Keyboard.LEFT))

[code]....

The problem im having with this code is the fact that theres an order it checks the keys due to the if/else statement.For example, if I was holding down the LEFT key and then simultaniously began holding down the RIGHT key, the RIGHT key's function would execute and override whatever the LEFT key's function was doing, since the RIGHT key is the first thing checked in the if/else statment.

The only work-around i can think of is making all the keys a single If statement, and a switch statement that controlls the movement. Which im having a lot of trouble getting to work at the moment...

View 1 Replies

ActionScript 2.0 :: Trigger If Statement When OnEnterFrame Crossed?

Jun 21, 2006

I have a movie clip called mover that I can ease up and down with buttons, and some action script to alpha a box if the top of the mover clip goes above the top of a stopper clip. Its an if statement and sadly only runs once. I made a controller movieclip which I thought would trigger the if statement each time the onEnterFrame was crossed... but sadly it doesnt work. I have attached a fla below.

View 3 Replies

ActionScript 2.0 :: [Flash CS4] Conditional Statement To Trigger An Event

Nov 30, 2008

I want to trigger an event when 4 buttons are being set to visible(originally set to ._visible=false at the beginning of the movie) say, the instance names of the buttons are "a","b","c",and "d", and their visibility is triggered by other events.When all of them are triggered/being set to visible, I want a movieclip to play (say, the name of the movieclip is "animation") I tried using the if statement and came up with the following code:

[Code]...

View 7 Replies

ActionScript 3.0 :: If Statement : Trigger If The Function Is Triggered By A Specific Movieclip?

Jan 10, 2010

I have a bunch of event listeners that refer to different movieclips but trigger the same function.I have an if statement within this function that I need to trigger if the function is triggered by a specific movieclip.

ActionScript Code:
//movieclip stuff....
addChild(backgroundPoint);
backgroundPoint.addEventListener(Event.ENTER_FRAME, animateBall);

[code]....

I know I could just create two separate functions but the code within the function (not shown here) is fairly long and I dont like repeating code.

View 2 Replies

Difference Of If Key.isDown And On KeyPress?

Aug 5, 2009

I was just wondering what the difference between these two is.

View 1 Replies

Key.IsDown Not Responding To Key Presses?

Feb 14, 2010

I'm following a simple tutorial on making a platformer, but I ran into a problem. This is the code I'm using in a player movie clip:

onClipEvent(enterFrame) {
if(this.character.hitTest(_root.bg.ground)==false) {
this._y+=_root.gravity;

[Code]....

When I press the keys, nothing happens, but if I replace the if statement with a 1 then the code executes fine.

View 1 Replies

ActionScript 2.0 :: Key.isDown Doesn't Work?

Apr 12, 2009

In the actions of a movie clip,I want to use something like:

PHP Code:
if(Key.isDown(W)){
//do stuff
}

But,it does not take anything else than LEFT,RIGHT and some others.I even tried ASCII:

PHP Code:
if(Key.isDown(100))
{}

It doesn't work.Then how do we use keys like W,A,S,D?

View 1 Replies

ActionScript 2.0 :: Setting Conditions For Key.isDown?

Apr 1, 2011

I have several input text boxes all of which are activated by the use of the enter key. I only want the one the user is using to run its script when they press enter instead of the keylistener on all of them picking up when enter is pressed. I have tried

ActionScript Code:
listenForEnterObject = new Object();
listenForEnterObject.onKeyDown=function(){

[code]....

View 1 Replies

ActionScript 2.0 :: Force Key.isDown Delay?>

Jun 5, 2011

I want to have it to that when i press up on my keyboard, my ball will jump up, and if i keep holding it down, it will not jump again until up is released and re-pressed.How my code looks right now

Code:
if (Key.isDown(Key.UP))
{
speedy = -30;
}
my ball's instance name is fivepointstar.

View 1 Replies

Professional :: Create *if (Key.isDown(Key.LEFT)* Allow Two Buttons?

Sep 8, 2011

if (Key.isDown(Key.LEFT) && Math.abs(this["speed"+who])>0.3) {
_root["car"+who]._rotation -= _root.rotationStep2*(this["speed"+who]/_root.maxSpeed);
}

[code].....

View 3 Replies

ActionScript 2.0 :: Using The Key.IsDown Commands To Change The Yscale?

Jul 28, 2009

so iv been using the Key.IsDown commands to change the yscale (of something), but i am at a loss at getting the yscale (of that something) back to the starting scale when the key is released.

View 3 Replies

ActionScript 2.0 :: Key.isDown Function - Moving Character

Jan 3, 2010

I have a character with multiple animations by way of movieclips, and I'm trying to have it move using the Key.isDown function. Now, my character is moving correctly, but when the key is released, the animation keeps playing. I tried adding a stop command at the end of the walkcycle animation, but that just causes the character to stay frozen on the last frame of the cycle.

Here is the ActionScript Code:
onClipEvent(load) {
var direction = "left";
var speed = 2;
} onClipEvent(enterFrame) {
[Code] .....

View 3 Replies

ActionScript 2.0 :: Key.isDown ... Three-key Combos - ASD Keys Won't Work

Mar 23, 2010

I'm working on a game where movement is controlled with WASD, and other commands are controlled with YUIOHJKLNM<>. The problem I'm encountering occurs when pressing down certain combinations of three keys. For example, when I'm holding down J and M, the ASD keys won't work; only W will. The same applies to J and N, and K and <; W is the only key of the movement commands that will work.

There is nothing in my programming that I can see or find that is causing this error; I've performed several tests and managed to pretty much isolate the problem being something to do with the keycodes. Does actionscript 2.0 have some inherent issues with certain 3-key combinations being pressed?

View 6 Replies

ActionScript 2.0 :: If Key.isDown, Stay Down - Toggle Switch?

Jun 16, 2011

How do I make it so that a key down function acts as a hard on/off switch, Instead of the momentary temporary toggle normally associated with "if Key.isdown"

Example: The "CONTROL" key is pressed, gotoAndPlay's an action, until the key is pressed again, which then gotoAndStop'S the action. Would I still use "if Key.isDown" or something else entirely.

View 8 Replies

ActionScript 2.0 :: Get A Letter To Execute A Key.isDown Action?

Oct 9, 2002

How do i get a letter to work inside of a key.isDown action?

View 6 Replies

ActionScript 2.0 :: If(Key.isDown) + Unload The Previous Movie Clips

Feb 5, 2009

I'm working on a pretty neat interactive music remixing site where you remix a song, then interact with a music video to make some cool stuff happen. I saw a few related posts on here, but I've got a bit of a more specific problem. originally I had the controls set so that whenever you click the mouse on the background (which I set as one giant blank button), that it would load a movie clip and unload the previous one:

[Code]....

This has been working fine, although now I'm trying to change the overall controls to assign every key on the keyboard to load a particular movie clip at the mouse x,y when pressed AND to unload the movie clip when it is pressed again. I think I might be applying the code to the wrong portion (in a blank frame in the timeline, not as part of any button or movie clip). I had the code setup so that I wasn't getting any errors, but nothing is happening when pressing the key. I also don't have a start on how to tell if a key has already been pressed, to perform a second action when pressed again (to unload the assigned movie clip). Here's what I've got so far:

[Code]...

View 0 Replies

ActionScript 2.0 :: MX: Trigger A MC Then Wait Then Trigger Another?

Aug 23, 2005

I have an application done in flash- on the main Scene Level, everything has only one frame but I have MCs and the like that are triggered by actionscript.There are quite a few nested functions on the main actions layer as well as an "onEnterFrame" function that reloads XML data in the background, etc... but that is not the problem.

The problem is, that at one point, I am calling a few MCs that kind of close up a section of the page like blinds- and then I want a text to appear ontop of that now closed area... but if I just write...

Code:
_root.TimelineFader.BlendeT1.gotoAndPlay(2);
_root.TimelineFader.BlendeT2.gotoAndPlay(2);
_root.TextAboveTimeline.theMessage_txt._visible = true;

...it all happens simultaneously, of course.I guess I could check for "BlendeT1"'s (or T2's) current frame (since it's an MC)... but how do I wait while that MC runs / until it reached a certain frame? How can I keep the rest of the actionscript in the main function from continuing?

View 5 Replies

ActionScript 2.0 :: First Requirement Of The If Statement When Type In The Proper Input And Go Straight To The Else Statement

May 14, 2009

Having a few problems with what I thought was a simple if statement. Here is the code:

[Code]...

I can't quite figure out the small problem with the code. It seems to just bypass the first requirement of the if statement when I do type in the proper input and go straight to the else statement.

View 7 Replies

ActionScript 1/2 :: Execute Code In Previous If Statement If Second If Statement Is Executed?

Aug 31, 2011

if (variable == 1){
//code
//Execute this code.
} else if (variable == 2) {
//code

[Code]...
 
I dont want to copy the code from the first into the second and the first and second into the third.
 
My mind isn't working and there is probably an extremelly simple way to get this working.
 
I know I could used functions but for some reason it stops the instance referencing working: _root["bullet"+j] doesnt work in a function.

View 7 Replies

ActionScript 2.0 :: Loading Data From XMl File And Uses It To Run An If Statement. If Statement Fails?

Oct 10, 2008

The Flash movie contains 2 Text files, one Component button, and 1 component checkbox.The purpose of the application is to load an XML file(works)Populate 2 text fields with information from the XML file(works)Compare the two text fields, if they contain the same information then the checkbox, via AS is told to be selected. (Heres the problem);

Heres the code:

Code:
runCode_btn.onPress = function() {
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = function(success) {

[code]....

The idea behind this app is that its an electronic form. The user fills it out, the information is then sent to a newly created XML file, months later the open the XML file in flash, and Flash fills out text fields and check and or unchecks Checkboxes based on the XML data.CheckBoxes are mandatory.But I don't see how I'll be able to use them if i can't create and condition statements based on the loaded Data.

View 1 Replies

ActionScript 2.0 :: If Statement Inside If Statement Won't Work

Mar 30, 2011

why this code won't work

[Code]...

I'm sure you can put if statements inside other if statements, seriously I can't figure it out

View 4 Replies

ActionScript 3.0 :: Another 'if' Statement Inside An 'if' Statement?

Sep 22, 2010

I need to write an if statement inside an if-else statement. But no matter how I write it it keeps giving me a syntax error.The syntax error is "1083: syntax error: else is unexpected".[code]No matter how or where I place the braces, it keeps giving me errors.

View 13 Replies

ActionScript 3.0 :: Use A For Statement To Create An If Statement

Jul 12, 2010

what I'm trying to do is create an else if argument for each object in an array based on a user set number

Code:
for(var i:int=0; i < numberOfElseIfs; i++){
GENERATE AS3 CODE
}

to which I want it to GENERATE THE FOLLOWING CODE:

Code:
}else if(baskets[i].used == false){
baskets[i].used = true;
drawButton(i);
}

the problem is obviously that the compiler reads this code rather than understanding I'm trying to regenerate the code within the for loop...does that make sense :S? So basically I need as3 to read the code between the for statement as if it is going to echo that out later. Is this even possible?

View 4 Replies

ActionScript 2.0 :: "Key.isDown()" - Navigate Using The Left And Right Arrow Keys On Keyboard

Nov 15, 2005

I'm building up an image resize gallery, and I want to navigate using the left and right arrow keys on my keyboard. I've been trying to figure this out a while now, but I can't get it working. Here's my code:

[Code]...

View 4 Replies

ActionScript 3.0 :: Write Another "if Statement" Inside Another If-else Statement?

Sep 22, 2010

I have a script which is giving me a lot of trouble since I have no idea how to write another "if statement" inside another if-else statement. I keep getting errors, I guess I don't know where to put the braces exactly...

example:
if(bla == bla) {
<------------how would I write another if statement here?
}else if (bla == bla){
}

View 3 Replies

Flash :: "IF" Statement, Within A For Statement, To Control Movieclip Within Movieclip?

Dec 18, 2011

I have a movieclip on the screen called "mc_bg". Within this movieclip are 7 movieclips called "barrier1" through "barrier7".From main.as I want to be able to do this call:

for (var i: int = 1; i < 3; i++ ){
trace("got here")
trace(mc_bg["mc_barrier" + String(i)])

[code]....

View 1 Replies

Mc Position Trigger Other Mc?

Jun 17, 2009

I have a mc which moves right or left depending on my mouse movement.the code is

onClipEvent(enterFrame) {
_x+= ((_root._xmouse/1.000001)*-1-_x)/120;
}

When the mc reaches certain x positions lets say x<-1000 ,another mc (which i placed inside this first mc)starts to play and stops or fades out when reaches to x<-2000 The best example is www.3nokta.net.You will understand what i mean I just need the mclips play or stop depending on the first mc position.

View 1 Replies

How To Trigger A Video

Aug 17, 2010

I have some videos that I want to show on my website through selecting from a flash component.If I program them in one flash component, I'm sure it will lag a lot.I have an html site and I want to trigger videos from the flash component.

View 4 Replies

ActionScript 3.0 :: How To Get InitKeys To Trigger

Mar 26, 2011

I'm trying to get initKeys to trigger. 'kiosk' is my base class.I'm getting error 1017: The definition of base class kiosk was not found.

project_folder/me/radbourne/kiosk.as

Code:

package me.radbourne {
import org.actionscript.*;
public class kiosk extends MovieClip {

[code]...

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved