1

ok, I have been trying to solve this myself for the better part of three days, with no luck. Here is a sample of code:

var text1:TextInput = new TextInput();
text1.text = "67"
for (var i:int = 1; i < 49;i++) {
    var test:int = int(["text" + i].text);
    trace(test);
}

this should output "67" but it only outputs "0". I have tried several combinations of bracket placement, with no luck. If I change the line:

    var test:int = int(["text" + i].text);

to this:

    var test:int = int(["text" + i] + ".text");

when i check the value in the debugger, it shows me that ["text" + i] + ".text" yields "text1.text", but not the string "67". any help would be greatly appreciated.

Thanks

Wes

1
  • You did almost right but you need to use this before square brackets where you put your computed string. Once you do, it'll work. Commented Jan 12, 2014 at 14:28

1 Answer 1

2

And what about using this keyword:

for (var i:int = 1; i < 49;i++) {
    var field:TextInput = this["text" + i];
    var test:int = int( field ? field.text : 0);
    trace(test);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.