createTextField

I tried everything, it works perfectly without the loop but when I try to put it in a loop it displays nothing.
I figured out it has something to do with the naming of mytext, It seems it needs to be quoted :frowning: I colored red where I think the fault is.


xwaarde = 20;
for(i=0;i<3;i++){
mytext = "mytext"+i;
_root.createTextField([COLOR=Red]mytext[/COLOR], i, xwaarde, 100, 50, 100);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = true;
mytext.text = "this is my first test field object text";
xwaarde = xwaarde+80;
}

the following works perfectly :


xwaarde = 20;
_root.createTextField("mytext", 0, xwaarde, 100, 50, 100);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = true;
mytext.text = "this is my first test field object text";

thanks

mytext.multiline = true; - this is addresing a “mytext” movie not “mytext”+i as you supposed.
Try using “with” … something like this.


xwaarde = 20;
for(i=0;i<3;i++){
mytext = "mytext"+i;
_root.createTextField(mytext, i, xwaarde, 100, 50, 100);
with ("mytext"+i){
multiline = true;
wordWrap = true;
border = true;
text = "this is my first test field object text";}
xwaarde = xwaarde+80;
}

Hope it works
Later Edit:
Actually a “with(mytext)” statement should work also
I believe it should work. I don’t have flash here and haven’t tested :slight_smile:
Let me know if works

nah… because mytext is a variable, hence the name of your text field depends upon a variable, you need to address it as such:

_root[mytext]

before each of your textfields properties will do the trick…

eg.

xwaarde = 20;
for(i=0;i<3;i++){
mytext = "mytext"+i;
_root.createTextField(mytext, i, xwaarde, 100, 50, 100);
_root[mytext].multiline = true;
_root[mytext].wordWrap = true;
_root[mytext].border = true;
_root[mytext].text = "this is my first test field object text";
xwaarde = xwaarde+80;
}

should work wivout a prob :wink:

Prophet.

is there something worng with the “with” statement?
I mean i used it that way when I had this problem… but maybe is this deprecated or something? Or is only a reason of habit?

Later Edit… My first post was indeed wrong but i told you I could be missing something :P. Forgoted the “eval”

with (eval(mytext))
{
text = "value";
}

thanks for the help guys