1

I've got a question about actionscript

E.g. three textboxes with names country1, country2, country3

how do I insert text into those textboxes using dynamic variables

e.g.

a="1"

b="2"

c="3"

["country" + a].text = "AAA"

["country" + a].text = "BBB"

["country" + a].text = "CCC"

Thanks

1
  • What actionscript version are you talking about? Commented Feb 10, 2011 at 9:49

2 Answers 2

1

HI,

If you can go, just so I know you have the code in the correct place.

country1.text = "hello"; // I assume that works.

then you can go.

this["country" + a].text = "AAA"; // Then that will work. 
Sign up to request clarification or add additional context in comments.

Comments

0

this["country" + a].text = "AAA"

Or something more complex:

var countries:Array = new Array();
countries['1'] = "UK";
countries['2'] = "Poland";
countries['3'] = "France";

for (key in countries){
    this["country" + key] = countries[key];
}

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.