Skip to main content
Participating Frequently
April 17, 2006
Answered

createTextField help...

  • April 17, 2006
  • 5 replies
  • 298 views
ok. im trying to get the data that is entered into the created text fields and turn them into an Array.
for some reason it reads the text field varibles as the variable name not the value of the text field.

anyone got any idea how to work this out?


the code:


word = "test_test";
amount = word.length;
letters = new Array();

for (x=0; x<amount; x++) {

xpos = 100;
xpos = xpos + x * 25;

createTextField("Box_"+ , x, xpos, 150, 20,20);
_root["Box_" + x].type = "input"
_root["Box_" + x].background=true;
_root["Box_" + x].border=true;
_root["Box_" + x].backgroundColor=0xFFFFFF;//white
_root["Box_" + x].borderColor=0x000000;//black
_root["Box_" + x].multiline=false;
_root["Box_" + x].wordWrap=false;
_root["Box_" + x].variable = "myText"+x
_root["Box_" + x].maxChars = 1;
_root["Box_" + x].tabEnabled = false;




btn.onPress = function(){
got = new Array(amount)
for(i=0; i<amount; i++){

got = "myText[" + i + "]";
trace(got);

}

}
This topic has been closed for replies.
Correct answer
I'm a bit confused what you are trying to achive.... perhaps this....

5 replies

April 17, 2006
well, that's what you tell it to do.
Why should it get the content when you set got = "myText["+i+"]";?
You probably mean got = _root["myText"+x];
But what are all these variables for in the first place?
Couldn't you work with _root["Box_" + x].text?
Also, you never set _root["Box_" + x].text to the letters.

And you have typos. I hope only in the copy:
- you're missing a ";" after the variable = "myText"+x
- you're missing a } after the loop
- and it should be "Box_"+x, not "Box_"+ inside createTextField("Box_"+ , x, xpos, 150, 20,20);
Participating Frequently
April 17, 2006
yea so thanks. but how do i set the the array "got" to equal what is entered into the text boxes.

i dont understand what you meant by this:

"Couldn't you work with _root["Box_" + x].text?
Also, you never set _root["Box_" + x].text to the letters."

and all of this will eventually be used for a crossword puzzle generator.
Correct answer
April 17, 2006
I'm a bit confused what you are trying to achive.... perhaps this....