如何访问数组元素数组、元素

2023-09-08 15:27:05 作者:深情不及酒伴

var count:uint = 0;
var textInputs:Array /* of TextInputs */ = [];
for(var i:String in columnsData){
    textInputs[count] = new TextInput();

    addChild(textInputs[count]);
    count++;
}

在这里,我怎么能访问第一,textinputs阵列的字符串或任何东西的形式第二,进一步进行

here how can i access the first, second of Array of textinputs in the form of string or any thing to further proceed

推荐答案

我不知道我是否理解你的问题是什么,但你不设置文本输入的值:

I am not sure if I understood what your question is, but you're not setting the value for text inputs:

我preFER了下列方式:

I prefer it the following way:

//make the array an instance variable instead of local var
//so that it can be accessed from other functions if required.
public var textInputs:Array = [];

for(var str:String in columnsData)
{
  var ti:TextInput = new TextInput();
  ti.text = str;
  addChild(ti);
  textInputs.push(ti);
}

您可以通过访问值 textInputs [0]的.text 等。

if(textInput != null){
  for(var i:Number = 0; i < textInputs.length; i++)
    trace(textInputs[i].text);
}
 
精彩推荐
图片推荐