Groups | Blog | Home
all groups > flash actionscript > april 2004 >

flash actionscript : create test boxes on the fly


Pluda
4/11/2004 8:54:54 PM
Hello,

I'm loading some records from an Mysql table and I need to create one textbox
for each record, so I can make diferent links to each one. How do I do that?

From Mysql, the vars come like this:

vars=Ana+Carrinho&Ant?nio+Maia&Hugo+Miguel&Ourivesaria+Tavares&

Thanks a lot

Pluda
Jack.
4/11/2004 10:48:19 PM
this will create textfields from the data you receive,
use something similiar with your button layout / data.

vars="Ana+Carrinho&Antonio+Maia&Hugo+Miguel&Ourivesaria+Tavares&";

str = vars.split("+").join(" ");
arr = str.split("&");
arr.pop();
for(var iv=0; iv!=arr.length; iv++){
this.createTextField("txt"+iv,iv,10,10+(20*iv),100,25);
this["txt"+iv].text = arr[iv];
}
Pluda
4/11/2004 11:20:33 PM
Hi Jack, thanks for help :-)

Something isn't well, because flash says that a scrip is causing flash to run
slowly...

This is the only scipt I have:

lv = new LoadVars();
lv.load("Phps_Txts/listar.php", 0);
lv.onLoad = function(){
str = vars.split("+").join(" ");
arr = str.split("\n");
arr.pop();
for(var iv=0; iv!=arr.length; iv++){
this.createTextField("txt"+iv,iv,10,10+(20*iv),100,25);
this["txt"+iv].text = arr[iv];
}

I'm sorry, my vars isn't as I said, sql returns this:


vars=Ana+Maria+Oliveira+Carrinho%0AAnt%C3%B3nio+Maia%0AAnt%C3%B3nio+Pires%0A%C3%
81lvaro+Montanha%0AHugo+Miguel+Teixeira+Carvalho%0AOurivesaria+Tavares%0APedro+A
niceto%0A

There is here some leters I just don't now what they are... Maibi its because
my language (portuguese) uses ?^~

In flash, loading this in one simple dinamic text box they apear as I need,
but I wanted them to be one in easch text field

I think the split must be in %0A, the other % are "?" and "?", but when
spliting in %0A flash almost "crashes"

What should I do?

Many thanks, this is based in your flash_db, but very changed to manage my
intents, and I need to use Mysql because I'm unther Macintosh and Macs dont
suport MDB's...

Thanks again :-)

Pluda
Jack.
4/11/2004 11:56:46 PM
you need something like -

tgt = this;

lv = new LoadVars();
lv.load("tester.txt"); // textfile - vars=Ana+Maria....
lv.onLoad = function(){
str1 = unescape(lv.vars);
str2 = str1.split("+").join(" ");
arr = str2.split("\n");
arr.pop();
for(var iv=0; iv!=arr.length; iv++){
tgt.createTextField("txt"+iv,iv,10,10+(20*iv),100,25);
tgt["txt"+iv].text = arr[iv];
}
};
Pluda
4/12/2004 1:01:27 AM
Allright Jack! :-)

You're surelly right!

You've been very kind to me, thanks man! :-)

If you need some sort of help (not in Flash, of course), please let me know,
ok? I'm a Graphic Designer, and I'm trying to be one Web Designer too :-)

Pluda
AddThis Social Bookmark Button