lty13900
06-24-2008, 09:23 PM
Any one could enlighten me how to create a random number of text field objects using only ActionScript?
p.r.o.n.t.o! thanks!
Hi,
You can use a for loop, something like...
for (i=0; i<10; i++) {
_root.createTextField("myText"+i, 10*i, 100*i, 200, 50, 50);
_root["myText"+i].border = true;
_root["myText"+i].text = "test";
_root["myText"+i].selectable = true;
_root["myText"+i].type = "input";
}
Now, if you want it to be random, just exchange the 10 in the for loop for a variable that selects a random number...
myAmount=random(10)+1;
for (i=0; i<myAmount; i++) {
_root.createTextField("myText"+i, 10*i, 100*i, 200, 50, 50);
_root["myText"+i].border = true;
_root["myText"+i].text = "test";
_root["myText"+i].selectable = true;
_root["myText"+i].type = "input";
}
hope it helps
NTD
Powered by vBulletin™ Version 4.1.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.