PDA

View Full Version : dynamic textfield creation


dex002
08-09-2005, 05:38 AM
This code is supposed to create a dynamic number of textfields and based on a loop. It almost works. The textfields are kind of there but not there. i.e. I can't see them, but when I hover over where they should be with my mouse, the mouse changes to a text tool, which makes me think I'm on the right track. Any ideas where I've gone wrong??


function GetGigs_Result( re:ResultEvent ):Void {
result_length = re.result.length;
i = 0
j = 0
while (i<result_length) {
gigs="<b>" + re.result[i].GIG + "</b>" + "<br>" + re.result[i].VENUE + "<br>" + re.result[i].ADDRESS + "<br>" + re.result[i].FGIG_DATE + re.result[i].TIME + "<br>" + re.result[i].COST;
i = i + 0
j = j + 100


this.createTextField("my_txt"+i,100+j,0,-300+j,100,100);
my_txt.html=true;
my_txt.multiline=true;
my_txt.wordWrap=true;
my_txt.htmlText=gigs;

}
}

function GetGigs_Fault( fe:FaultEvent ):Void {
gigs_txt.htmlText = "Sorry, there is a problem. Please try again."
}

Ricod
08-09-2005, 06:17 AM
I could be wrong, but it looks like you don't increment i, so shouldn't this result in an infinite loop ?

But since the text part is going wrong, I'm guessing that 'gigs' doesn't hold any data. Did you trace 'gigs' to see if it returns anything at all ?

dex002
08-09-2005, 06:30 AM
Hey thanks for getting back to me. I made a mistake when posting the code, it does increment properly and gigs traces ok. I think it must be something else.

Here's the correct code:


function GetGigs_Result( re:ResultEvent ):Void {
result_length = re.result.length;
var gigs = ""
i = 0
j = 0
while (i<result_length) {
gigs="<b>" + re.result[i].GIG + "</b>" + "<br>" + re.result[i].VENUE + "<br>" + re.result[i].ADDRESS + "<br>" + re.result[i].FGIG_DATE + re.result[i].TIME + "<br>" + re.result[i].COST;

i = i + 1
j = j + 110


this.createTextField("my_txt"+i,100+j,0,-300+j,100,100);
my_txt.html=true;
my_txt.multiline=true;
my_txt.wordWrap=true;
my_txt.htmlText=gigs;
trace(gigs)
}
}

SmackMe
08-09-2005, 09:32 AM
May be you are masking the textareas. Dynamic text doesn't render when it is masked.

Cheers!

Ricod
08-09-2005, 10:51 AM
Good point ! I think you can though, by embedding the font. Or was that just for input text ? :rolleyes:

dex002
08-09-2005, 10:34 PM
No, there's nothing else on the stage at all, so its not a masking problem. I might try embedding the fonts in any case.

deadbeat
08-09-2005, 10:51 PM
Well, you are naming your text fields "my_txt"+i, but you are only setting the properties as my_txt...so the fields are probably being created properly, but not populated with the text...

Try:

this.createTextField("my_txt"+i,100+j,0,-300+j,100,100);
this["my_txt"+i].html=true;
this["my_txt"+i].multiline=true;
this["my_txt"+i].wordWrap=true;
this["my_txt"+i].htmlText=gigs;


K.

dex002
08-09-2005, 10:54 PM
Deadbeat, I love you even more.