2011-02-10 75 views
1

我有一个关于actionscript的问题actionscript动态变量

E.g.三个文本框与名称COUNTRY1,COUNTRY2,COUNTRY3

我怎么使用动态变量

例如文本插入文本框的那些

一个= “1”

B = “2”

C = “3”

[ “国家” +α]的.text = “AAA”

[”国” +α]的.text = “BBB”

[ “国家” +α]的.text = “CCC”

由于

+0

什么动作的版本你在说什么? – 2011-02-10 09:49:27

回答

1

嗨,

如果你可以去,只是让我知道你的代码在正确的位置。

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

然后你可以去。

this["country" + a].text = "AAA"; // Then that will work. 
0

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

或者更复杂的东西:

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

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