如何访问数组元素 [英] How to access the array elements
本文介绍了如何访问数组元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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);
}
这篇关于如何访问数组元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文