开发者

How to get dynamic TextInput field values in Actionscript 3

Hi creating dynamic TextInput fields in a function. Need to get the values of those fields in another function. Can anyone throw some light on this.

for(var i:int=0;i<answers.length;i++)
                {       
             开发者_JAVA百科       txtbox = new spark.components.TextInput();                  
                    var lblBox:spark.components.Label = new spark.components.Label();                   
                    lblBox.id = "lbl"+i.toString();
                    lblBox.text = String(answersLabel.getItemAt(i) );
                    lblBox.width = 10
                    lblBox.x = xPos-15;
                    lblBox.y = yPos;
                    QuestionAnswer.addElement(lblBox);                  
                    txtbox.id   = "text"+i.toString();
                    txtbox.x = xPos;
                    txtbox.y = yPos;
                    QuestionAnswer.addElement(txtbox);                  
                    xPos += 200;
                }


var txt:TextField;
var i:uint;
var ary:Array = new Array();
function txtCreation ():void {
    for( i=0;i<5;i++)
    {
        txt = new TextField();
        txt.text = "txt"+i;
        addChild(txt);
        txt.x = 50 + txt.width *i;
        txt.y = 20;
        ary.push(txt);  
    }
}
txtCreation();

for(i=0;i<ary.length;i++)
{
    trace("array values : " +ary[i].text);
}


Just look at the text variable for the textfield.

var textFromField : String = myInputText.text;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜