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]
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:
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:
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:
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?