如何通过as3中的按钮创建新的文本字段?

时间:2016-03-20 20:41:13

标签: actionscript-3

我现在永远都有这个问题。我想要做的就是创建一个按钮,添加一个位于前一个文本字段正下方的新(输入)文本字段(或许,用户创建一个包含一定数量项目的项目符号列表)。

这是我到目前为止的代码(与该主题有关)

function addCompanySlotButton(b:MouseEvent){
for(var i:Number = 0;i<slotArray.length;i++){ //slotArray holds the number of text fields (slots) that exist.
    company_slot.name = "slot"+(i); //This is supposed to name the newly-created text field by its index number. (company_slot is just a variable name for the text fields)
    company_slot.y = 30*slotArray.length; //This is supposed to move the newly-created index slot down by 30 * (whatever it's index number is).
    company_slot.x = 75;
    company_container.addChild(company_slot); //company_container is just a display object that shows the text fields/company slots.
}
slotArray.push(company_slot);
trace(slotArray.length); //This number increases every time the button is pressed, so I know for sure that there is more than one text field.
}

但是,似乎所有文本字段都在同一个位置,并且每当按下按钮时,所有这些字段都移动而不是仅移动一个。我对动作脚本(以及一般的编码)都很陌生,所以非常感谢任何帮助。

0 个答案:

没有答案
相关问题