PDA

View Full Version : I can't make it work


redshark
11-07-2003, 05:27 PM
I want to make serveral text boxes the correct way is createTextField, but I donīt know the number cause it is a variable. I'm using an array for getting this number


nom_array = new Array(city,city1,city2,city3,city4,city5,city6,cit y7);
var m = nom_array.length + 1;
for (i = 0; i < m; i++){
if (i < m - 1){
mytext1 = "mytext1"+i;

createTextField(mytext1, (i+1), sxpos + 10, sypos, 100, 20);
mytext1.multiline = true;
mytext1.wordWrap = true;
mytext1.autoSize = true;
mytext1.border = true;
myformat = new TextFormat();
myformat.selectable=false;
myformat.color = 0xff0000;
myformat.font = "Verdana";
mytext1.text = city;
mytext1.setTextFormat(myformat);
}
else
stop();
}



I've read all the posts end I still canīt find why i doesnīt work. Also the mytext1.autoSize isnīt working.
Thanks very much in advanced

nunomira
11-07-2003, 10:01 PM
hi,

depending on what you want...

var m = nom_array.length; //don't you want the lengt of the array?

for (i = 0; i < m; i++) {
mytext1 = "mytext1" + i; // this is a string
createTextField(mytext1, i + 1, sxpos + 10, sypos, 100, 20); // be careful because this places the text fields on top of eachother
mytext1 = eval(mytext1); // this is an indentifier
mytext1.multiline = true;
mytext1.wordWrap = true;
mytext1.autoSize = true;
mytext1.border = true;
myformat = new TextFormat();
myformat.selectable = false;
myformat.color = 0xff0000;
myformat.font = "Verdana";
mytext1.text = city;
mytext1.setTextFormat(myformat);
}

usually it would be something like this:

createTextField(mytext1, i + 1, sxpos + 10+20*i, sypos, 100, 20);


One more thing:
This has nothing to do with actionscript 2.0. Just because you're using MX2004, doesn't mean you're using actionscript 2.0

For example:

var nom_array:Array = new Array(...);
var m:Number = nom_array.length;

would be a good excuse to post here
:p