Flash - assign text input data to string

268 Views Asked by At

i have a text input box in my flash actionscipt 3.0 file, and want to assign the text in it to a tring, like for say, if i type in bill, the string is set to bill, and i can use an if statement to see that its bill and run a command. Any help?

I've tried: public String cmd = cmdline.text;

but pubic can only be used in packages, so i tried: String cmd = cmdline.text;

but that didn't work it said it was looking for a defining keyword.

So i have no idea what to do

1

There are 1 best solutions below

4
On

In Flash, variables are created using the var keyword. So in your case, you'd want to go with something like:

var cmd:String = cmdline.text;

If you're looking to do a check on the text field's value after user input, you'll want to look into using keyboard events in order to listen for user input. More info on them can be found here:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/KeyboardEvent.html