arrays - AS3 - Best method for dynamically creating a series of text fields? -


i (successfully) creating column of boxes via loop, meat of is:

for(var i=0;  < max_rows + 1; i++){                 for(var o=0; o < max_cols + 1; o++){                     var currenttile:memberbox = new memberbox();                     currenttile.x = i*150;                     currenttile.y = o*25;                     currenttile.name = "b"+o;                     memberbox.addchild(currenttile); }} 

now need add textfield each box, later populated data array. tried adding each textfield array in loop , calling array, textfields still have same name last 1 called works...

here have - need, adds text last box created.

var txtarray:array = new array();  for(var i=0;  < max_rows + 1; i++){ for(var o=0; o < max_cols + 1; o++){ var currenttile:memberbox = new memberbox(); currenttile.x = i*150; currenttile.y = o*25; currenttile.name = "b"+o; memberbox.addchild(currenttile);  currenttile.addchild(memberboxtext); memberboxtext.width = 150; memberboxtext.height = 25; txtarray[o] = memberboxtext; txtarray[o].text = "test"+o; }} 

well didn't declare anywhere memberboxtext asume added manually through flash builder. not making new instance of textfield.try inserting loop: var membertxt:textfield=new textfield(); currenttile.addchild(membertxt); :)


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -