# "If" statement

**URL:** <https://forum.kirupa.com/t/if-statement/182593>\
**Category:** flash\
**Created:** [March 19, 2006, 9:19pm UTC](https://forum.kirupa.com/t/if-statement/182593 "2006-03-19T21:19:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonytsou912](https://avatars.discourse-cdn.com/v4/letter/t/7ba0ec/32.png) [@tonytsou912](https://forum.kirupa.com/u/tonytsou912)\
**Post date:** [March 19, 2006, 9:19pm UTC](https://forum.kirupa.com/t/if-statement/182593/1 "2006-03-19T21:19:56Z")

</div>

I’m trying to use a “if statement” so that if a textfield is filled out before the timeline runs the end, the movie will go to a different scene than if the textfield is not filled out before the time runs out. Can any one please tell me how I can do that? THANK YOU!

---

<div class="post-metadata">

**Author:** ![Jeff\_Wheeler](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jeff\_Wheeler](https://forum.kirupa.com/u/Jeff_Wheeler)\
**Post date:** [March 19, 2006, 9:22pm UTC](https://forum.kirupa.com/t/if-statement/182593/2 "2006-03-19T21:22:01Z")

</div>

On the last frame of the scene, do something to the effect of this pseudo-code:

```auto
if (isFilled(textField)) { // You'll need to define isFilled() with your check
    // go to the scene
} else {
    // go to the other scene
}

```

---

<div class="post-metadata">

**Author:** ![smoothhabitat](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@smoothhabitat](https://forum.kirupa.com/u/smoothhabitat)\
**Post date:** [March 19, 2006, 9:36pm UTC](https://forum.kirupa.com/t/if-statement/182593/3 "2006-03-19T21:36:52Z")

</div>

if (txtInstanceName.text!="") {  
// go to the scene  
} else {  
// go to the other scene  
}

---

<div class="post-metadata">

**Author:** ![tonytsou912](https://avatars.discourse-cdn.com/v4/letter/t/7ba0ec/32.png) [@tonytsou912](https://forum.kirupa.com/u/tonytsou912)\
**Post date:** [March 20, 2006, 3:10am UTC](https://forum.kirupa.com/t/if-statement/182593/4 "2006-03-20T03:10:43Z")

</div>

what if i want to it go to another scene immediately after the textfield is filled up?

---

<div class="post-metadata">

**Author:** ![matthewjumps](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@matthewjumps](https://forum.kirupa.com/u/matthewjumps)\
**Post date:** [March 20, 2006, 3:20am UTC](https://forum.kirupa.com/t/if-statement/182593/5 "2006-03-20T03:20:55Z")

</div>

when you say filled do you mean the txtfield is going to gradually get more and more text in it until it reaches a certain point? or are you saying you want this to work as soon as any content gets put into the txtfield even one letter like “a” or whatever?

---

<div class="post-metadata">

**Author:** ![tonytsou912](https://avatars.discourse-cdn.com/v4/letter/t/7ba0ec/32.png) [@tonytsou912](https://forum.kirupa.com/u/tonytsou912)\
**Post date:** [March 20, 2006, 3:22am UTC](https://forum.kirupa.com/t/if-statement/182593/6 "2006-03-20T03:22:23Z")

</div>

I meant when it reaches a certain point

---

<div class="post-metadata">

**Author:** ![matthewjumps](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@matthewjumps](https://forum.kirupa.com/u/matthewjumps)\
**Post date:** [March 20, 2006, 3:27am UTC](https://forum.kirupa.com/t/if-statement/182593/7 "2006-03-20T03:27:40Z")

</div>

TextField.length returns the number of characters in a texfield…you might want to use

```auto

if(TextField.length >= 100){
    //do stuff
} 

```

---

<div class="post-metadata">

**Author:** ![tonytsou912](https://avatars.discourse-cdn.com/v4/letter/t/7ba0ec/32.png) [@tonytsou912](https://forum.kirupa.com/u/tonytsou912)\
**Post date:** [March 20, 2006, 3:41am UTC](https://forum.kirupa.com/t/if-statement/182593/8 "2006-03-20T03:41:23Z")

</div>

how do I use that with this code, because if I just simply plugging it in, somehow an error will pop up.

var characters:Array = new String(“two roads diverged in a yellow wood and sorry i could not travel both”).split("");  
this.createTextField(“txt”, 1, 10, 260, 515, 22);  
txt.border = true;  
txt.background = true;  
Key.addListener(txt);  
txt.onChanged = function():Void {  
Ferrari.\_x += 6.3;  
};  
txt.onKeyDown = function():Void {  
if (String.fromCharCode(Key.getCode()).toLowerCase() == characters[txt.length].toLowerCase()) {  
this.text += String.fromCharCode(Key.getCode());  
this.onChanged();  
}  
}

---

<div class="post-metadata">

**Author:** ![matthewjumps](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@matthewjumps](https://forum.kirupa.com/u/matthewjumps)\
**Post date:** [March 20, 2006, 3:45am UTC](https://forum.kirupa.com/t/if-statement/182593/9 "2006-03-20T03:45:53Z")

</div>

:huh: i dunno
