# Textfield

**URL:** <https://forum.kirupa.com/t/textfield/182492>\
**Category:** flash\
**Created:** [March 18, 2006, 8:39pm UTC](https://forum.kirupa.com/t/textfield/182492 "2006-03-18T20:39:05Z")\
**Posts on this page:** 3\
**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 18, 2006, 8:39pm UTC](https://forum.kirupa.com/t/textfield/182492/1 "2006-03-18T20:39:05Z")

</div>

Can anyone please tell me why when I use the following actionscript  
**[COLOR=black][FONT=‘Courier New’][/FONT][/COLOR]**  
**[COLOR=black][FONT=‘Courier New’]var[/FONT][/COLOR]**[COLOR=black][FONT=‘Courier New’] characters:[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]Array[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’] = **new** [/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]String[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’]([/FONT][/COLOR][COLOR=red][FONT=‘Courier New’]“kirupa”[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’]).[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]split[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’]([/FONT][/COLOR][COLOR=red][FONT=‘Courier New’]""[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’]);  
[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]this[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’].[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]createTextField[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’]([/FONT][/COLOR][COLOR=red][FONT=‘Courier New’]“txt”[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’], [/FONT][/COLOR][COLOR=navy][FONT=‘Courier New’]1[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’], [/FONT][/COLOR][COLOR=navy][FONT=‘Courier New’]10[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’], [/FONT][/COLOR][COLOR=navy][FONT=‘Courier New’]10[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’], [/FONT][/COLOR][COLOR=navy][FONT=‘Courier New’]150[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’], [/FONT][/COLOR][COLOR=navy][FONT=‘Courier New’]22[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’]);  
txt.[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]border[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’] = **true** ;  
[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]Key[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’].[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]addListener[/FONT][/COLOR][COLOR=black]FONT=‘Courier New’;  
txt.[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]onKeyDown[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’] = **function** ():[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]Void[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’] {  
[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]if[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’] ([/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]String[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’].[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]fromCharCode[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’]([/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]Key[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’].[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]getCode[/FONT][/COLOR][COLOR=black]FONT=‘Courier New’).[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]toLowerCase[/FONT][/COLOR][COLOR=black]FONT=‘Courier New’ == characters[txt.[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]length[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’]]) {  
txt.[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]text[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’] += [/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]String[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’].[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]fromCharCode[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’]([/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]Key[/FONT][/COLOR][COLOR=black][FONT=‘Courier New’].[/FONT][/COLOR][COLOR=blue][FONT=‘Courier New’]getCode[/FONT][/COLOR][COLOR=black]FONT=‘Courier New’);  
}  
}[/FONT][/COLOR]  
[COLOR=black][FONT=‘Courier New’][/FONT][/COLOR]  
[COLOR=black][FONT=‘Courier New’][FONT=Verdana]My [FONT=Courier New]txt.[COLOR=blue]onChanged[/COLOR][/FONT] function stops working? Because I’m trying to make it so that the user can only type in specific letters in a specific order, and if they do, a picture on the screen will move.[/FONT][/FONT][/COLOR]  
[COLOR=black][FONT=‘Courier New’][FONT=Verdana][/FONT][/FONT][/COLOR]  
[COLOR=black][FONT=‘Courier New’][FONT=Verdana]Pleeeeeeeeaaaaaase tell me what I should do! Thank you![/FONT][/FONT][/COLOR]

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [March 19, 2006, 12:55am UTC](https://forum.kirupa.com/t/textfield/182492/2 "2006-03-19T00:55:32Z")

</div>

> [@Flash Help File](#):
>
> The onChanged handler is called only when the change results from user interaction; for example, when the user is typing something on the keyboard, changing something in the text field using the mouse, or selecting a menu item. Programmatic changes to the text field do not trigger the onChanged event because the code recognizes changes that are made to the text field.

As it says, when you make programmatic changes whoever wrote the TextField class assumes that you will know that you are in fact making these changes. Either this:

```auto
var characters:Array = new String("kirupa").split("");
this.createTextField("txt", 1, 10, 10, 150, 22);
txt.border = true;
Key.addListener(txt);
txt.onChanged = function():Void {
 //code you want to execute when text is added to the text field
};
txt.onKeyDown = function():Void {
 if (String.fromCharCode(Key.getCode()).toLowerCase() == characters[txt.length].toLowerCase()) {
  this.text += String.fromCharCode(Key.getCode());
  this.onChanged();
 }
};

```

or this:

```auto
var characters:Array = new String("kirupa").split("");
this.createTextField("txt", 1, 10, 10, 150, 22);
txt.border = true;
Key.addListener(txt);
txt.onKeyDown = function():Void {
 if (String.fromCharCode(Key.getCode()).toLowerCase() == characters[txt.length].toLowerCase()) {
  this.text += String.fromCharCode(Key.getCode());
  //code you want to execute when text is added to the text field
 }
};

```

Up to you :hr:

---

<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:34am UTC](https://forum.kirupa.com/t/textfield/182492/3 "2006-03-20T03:34:02Z")

</div>

Um…I have another question…I just realized that the movie kinda “carries” the textfield into the next scene even though I only wanted it in one of the scenes. Is there anyway I can stop that?
