Groups | Blog | Home
all groups > flash actionscript > may 2005 >

flash actionscript : My usual problem - split an array into value pairs


Pluda
5/1/2005 12:00:00 AM
Hello,

I need to split one array into value pairs - one text and one image - to be
able to make a kind of a latest news file

My php echoes this:


vars=texto%3DAlguma+vez+se+sabe+quem%3F%26icone%3D1%0Atexto%3Dteste2%26icone%3D2
%0Atexto%3Djiojij%26icone%3D5

I need to loop this and split it to have

texto1 = "bla bla bla";
icone1 = 1;

texto2 = "ble ble ble";
icone2 = 2

Can someone please help me?
I need to have this working until tomorrow...

Thanks!

Pluda
Pluda
5/2/2005 12:00:00 AM
Hello David,

Thanks for reply, i had to stop flash development due to my graphical work,
but I'm back!
Hope to ear from you :-)

Well, yes, your sugestion makes all sense, and I got it working like that

my php now echoes this:

textos=Alguma+vez+se+sabe+quem%3F%0Ateste2%0Ajiojij%0A&icones=1%0A3%0A5%0A

I have here 3 textos and 3 icones to load into flash, I limit the database
search to 3 rows

Now I had to create 3 textfields whose text = textos and 3 movieclips to load
the images (icones)

I made this code in flash, do you think that I can improve it?

Many thanks! :-)

Pluda


loaddestaques = new LoadVars();
//loaddestaques.load("php/destaques.txt");
loaddestaques.load("php/destaques.php?unique="+sem_cache+"&tabela=destaques");
loaddestaques.onLoad = function(sucesso) {
if (sucesso) {
txts = unescape(loaddestaques.textos);
txt = txts.split("\n");
txt.sort();
// para remover a virgula antes do n? da imagem
txt.splice(0, 1);
//
icones = unescape(loaddestaques.icones);
icone = icones.split("\n");
icone.sort();
// para remover a virgula antes do n? da imagem
icone.splice(0, 1);
trace(icone);
//
for (i=0; i<txt.length; i++) {
for (j=0; j<icone.length; j++) {
r.createTextField("destaques"+i, 7+i, 10, 10, 165, 93);
r["destaques"+i]._x = 10;
r["destaques"+i]._y = 25+i*103;
//
r.createEmptyMovieClip("icone_destaques"+j, 100+j);
trace(r["icone_destaques"+j]);
r["icone_destaques"+j]._x = r["destaques"+i]._x+r["destaques"+i]._width+15;
r["icone_destaques"+j]._y = 25+j*103;
//
pic = icone[j];
//
r["icone_destaques"+j].loadMovie("pics/icones/icone_"+pic+".jpg");
//
r["destaques"+i].html = true;
r["destaques"+i].htmlText = txt[i];
r["destaques"+i].embedFonts = true;
r["destaques"+i].multiline = true;
r["destaques"+i].wordWrap = true;
r["destaques"+i].selectable = false;
r["destaques"+i].setTextFormat(f1);
}
}
}
};
David Stiller
5/2/2005 11:05:01 AM
Pluda,

[quoted text, click to view]

It looks as if you're making this more complicated than it needs to be.
You have one huge name/value pair ...

vars = [long urlencoded string]

.... if you had PHP simply echo value of vars, the multiple name/value pairs
would already be taken care of. In other words, have PHP echo this:

texto1=Alguma%20vez%20se%20sabe%20quem%3F&icone1=1&texto2=teste2&icone2=2&texto3=jiojij&icone3=5

Does that make sense?


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

David Stiller
5/3/2005 12:00:00 AM
Pluda,

[quoted text, click to view]

Nice. :)

[quoted text, click to view]

Actually, Pluda, I have a hard time following your ActionScript because
of the variable names (just like before!). But I know you're good with
ActionScript. I still have your multiple preloader code, so it's probably
just fine. :)


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Pluda
5/3/2005 11:44:19 PM

But I know you're good with
ActionScript. I still have your multiple preloader code, so it's probably
just fine. :)



Thanks David, I hope my multiple preloader helps on your flash developments

I'm not so good as I want and need to be, but I'm trying, and I'm counting
with you and some other great actionscripters in this forums to help me.

Many thanks! :-)

Pluda
AddThis Social Bookmark Button