我有以下问题:
我有一个接收多个变量的函数:
function test( fooValue:String, foobar1:String, foobar2:String, goobar1:String, goobar2:String ) {
//using the values statically
mytext1.text = foobar1;
mytext2.text = foobar2;
mytext3.text = goobar1;
mytext4.text = goobar2;
if ( goobar1 = "problem" ) {
myProblem.text = this["foo" + fooValue] + this["goo" + fooValue];
}
}
//now here's an example call
test( "bar1","first value ","second value ", "another value", "yet another value");
鉴于 fooValue 在上述调用中具有“bar1”这一事实,我怎样才能使 myProblem.text 显示“第一个值另一个值”
this[ "foo" + fooValue] 给我 undefined
- 编辑了问题并试图更具体。