# Help with IF Script

**URL:** https://forum.kirupa.com/t/help-with-if-script/63364
**Category:** flash
**Created:** [September 6, 2004, 1:43am UTC](https://forum.kirupa.com/t/help-with-if-script/63364 "2004-09-06T01:43:00Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![gregminderkai](https://avatars.discourse-cdn.com/v4/letter/g/ce73a5/32.png) [@gregminderkai](https://forum.kirupa.com/u/gregminderkai)
#### Post date: [September 6, 2004, 1:43am UTC](https://forum.kirupa.com/t/help-with-if-script/63364/1 "2004-09-06T01:43:00Z")

</div>

[font=verdana, arial, helvetica][size=2]if (abort eq “95743G29V8X0”) {

```
stop;

```

}

I have Flash MX 2004 Pro. I wanna make it so I can press the enter key on the keyboard when I type the code in to make my countdown stop.[/size][/font]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 6, 2004, 7:02pm UTC](https://forum.kirupa.com/t/help-with-if-script/63364/2 "2004-09-06T19:02:53Z")

</div>

erm to run an action when your enter key is pressed, have this code (best on an onEnterFrame)

```auto
if(Key.isDown(Key.ENTER)){
    //your actions here
}

```

Prophet.

PS for IF/ELSE mini tut, see here: [http://www.kirupaforum.com/forums/showthread.php?p=608900&posted=1](http://www.kirupaforum.com/forums/showthread.php?p=608900&posted=1)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 6, 2004, 8:27pm UTC](https://forum.kirupa.com/t/help-with-if-script/63364/3 "2004-09-06T20:27:50Z")

</div>

That didn’t work. Heres what I did- if(Key.isDown(Key.ENTER))  
//if(abort eq “95743G29V8X0”) }  
stop();  
I put that in but it didn’t work.

> [@Prophet](#):
>
> erm to run an action when your enter key is pressed, have this code (best on an onEnterFrame)
> 
> ```auto
> if(Key.isDown(Key.ENTER)){
> //your actions here
> }
> 
> ```
> 
> Prophet.
> 
> PS for IF/ELSE mini tut, see here: [http://www.kirupaforum.com/forums/showthread.php?p=608900&posted=1](http://www.kirupaforum.com/forums/showthread.php?p=608900&posted=1)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 6, 2004, 8:46pm UTC](https://forum.kirupa.com/t/help-with-if-script/63364/4 "2004-09-06T20:46:54Z")

</div>

That didn’t work. Heres what I did- if(Key.isDown(Key.ENTER))  
//if(abort eq “95743G29V8X0”) }  
stop();  
I put that in but it didn’t work.  
:S  
if(Key.isDown(Key.ENTER)) **{**  
//if(abort eq “95743G29V8X0”)  
stop();  
}

You missed the opening bracket, and whats abort eq “95743G29V8X0”??  
And I assume you want the stop(); within the conditin

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 6, 2004, 8:54pm UTC](https://forum.kirupa.com/t/help-with-if-script/63364/5 "2004-09-06T20:54:56Z")

</div>

Heres what I did I made a timer that counts down from 12, and I put the script if(abort eq “95743G29V8X0”) and the 95743G29V8X0 is an abort code its supposed to make the timer stop counting but it doesn’t.

> [@ntshp](#):
>
> That didn’t work. Heres what I did- if(Key.isDown(Key.ENTER))  
> //if(abort eq “95743G29V8X0”) }  
> stop();  
> I put that in but it didn’t work.  
> :S  
> if(Key.isDown(Key.ENTER)) **{**  
> //if(abort eq “95743G29V8X0”)  
> stop();  
> }
> 
> You missed the opening bracket, and whats abort eq “95743G29V8X0”??  
> And I assume you want the stop(); within the conditin

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 6, 2004, 9:32pm UTC](https://forum.kirupa.com/t/help-with-if-script/63364/6 "2004-09-06T21:32:01Z")

</div>

```auto
if(Key.isDown(Key.ENTER)){
    if (abort eq "95743G29V8X0") {
        stop()
    }
}

```

sorry, i guessed you would understand that

```auto
//

```

means its a comment and as such flash ignores these lines of code… the above should work… assuming your stopping an animation on the \_root level and your original IF statement will equate to true…

Prophet.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 6, 2004, 9:37pm UTC](https://forum.kirupa.com/t/help-with-if-script/63364/7 "2004-09-06T21:37:48Z")

</div>

I still don’t get it? Help me? Nothing works. It still won’t stop.

QUOTE=Prophet]

```auto
if(Key.isDown(Key.ENTER)){
      if (abort eq "95743G29V8X0") {
          stop()
      }
 }

```

sorry, i guessed you would understand that

```auto
//

```

means its a comment and as such flash ignores these lines of code… the above should work… assuming your stopping an animation on the \_root level and your original IF statement will equate to true…

Prophet.[/QUOTE]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 6, 2004, 10:39pm UTC](https://forum.kirupa.com/t/help-with-if-script/63364/8 "2004-09-06T22:39:13Z")

</div>

Could you please post your fla, we will just end up coming round in circles otherwise

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 6, 2004, 10:41pm UTC](https://forum.kirupa.com/t/help-with-if-script/63364/9 "2004-09-06T22:41:27Z")

</div>

The fla is too big.

> [@ntshp](#):
>
> Could you please post your fla, we will just end up coming round in circles otherwise

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 6, 2004, 11:14pm UTC](https://forum.kirupa.com/t/help-with-if-script/63364/10 "2004-09-06T23:14:30Z")

</div>

I din’t quite understood what your timer whould be?  
if ist’s a variable displayed with the help of getTimer(); you won’t be able to stop it with a stop(); action. That is for movieclips.

If you by timer were reffering to a movieclip then put this code on it

```auto
onClipEvent (enterFrame) {
	if(Key.isDown(Key.ENTER)) {
                         if (abort eq "whatever") {
                         stop();
                        }
	} 
}

```

Or try using a listener

```auto

asdfg = new Object();
asdfg.onKeyDown = function() {
	if (Key.isDown(Key.ENTER)) {
		trace("You pressed enter.");
                           if (abort eq "thatthingcode") {
                           stop();\\ i guess
                           }
	}
};
Key.addListener(asdfg);

```
