PDA

View Full Version : alternate color displaying multiple records


majin
03-28-2003, 04:35 PM
I would like to alternate colors displaying multiple records
here my AS which not work
(I've put inside MC instance messaggio a MC instance bgLista)

// set the initial movie messaggio visibility to 0

pari = true;
depth = -1;
messaggio._visible = 0;
// create the author array from the list loaded from CF
ListaIdmessaggio_array = ListaIdmessaggio.split(",");
ListaDataora_array = ListaDataora.split(",");
ListaNickname_array = ListaNickname.split(",");
ListaOggetto_array = ListaOggetto.split(",");
// get the length of the array and loop this many times
// author_length = author_array.length;
array_length = ListaIdmessaggio_array.length;
// set the initial y position of the messaggio
yposition = 40;
// begin looping
for (i=0; i<array_length; i++) {
pari = not pari;
duplicateMovieClip(messaggio, "messaggio" add i, depth);
setProperty("messaggio" add i, _y, yposition);

if (pari) {
coloreLista = new Color(messaggio.bgLista);
coloreLista.setRGB(0xF7F7F7);

} else {
coloreLista = new Color(messaggio.bgLista);
coloreLista.setRGB(0xF7F7F7);

}
set("messaggio" add i add ".ListaIdmessaggio", ListaIdmessaggio_array[i]);
set("messaggio" add i add ".ListaDataora", ListaDataora_array[i]);
set("messaggio" add i add ".ListaNickname", ListaNickname_array[i]);
set("messaggio" add i add ".ListaOggetto", ListaOggetto_array[i]);
depth--;
yposition = yposition+25;
}

Thanks in advance
majin

tg
03-28-2003, 05:04 PM
try it this way:

coloreLista = new Color(messaggio.bgLista);
i%2==0 ? coloreLista.setRGB(0xeeeeee) : coloreLista.setRGB(0xffffff);

or this way:

coloreLista = new Color(messaggio.bgLista);
if (i%2==0) {
coloreLista.setRGB(0xeeeeee);
} else {
coloreLista.setRGB(0xffffff);
}

tg
03-28-2003, 05:08 PM
of course, you do realize that your code *might* work, but both conditions of your if statement are using the SAME color (0xF7F7F7).

majin
03-28-2003, 05:42 PM
thanks for answers,

but the problem is that if I put at top of the code

coloreLista = new Color(messaggio.bgLista);
coloreLista.setRGB(0xF7F7F7);

messaggio._visible = 1;

at least should change color of bgLista and it doesn't

I've only under the first clip messaggio

the "original" (not generated) clip messaggio with color set right

thanks majin

tg
03-28-2003, 06:06 PM
not sure i understand you, but try this for loop:

for (i=0; i<array_length; i++) {
mess=duplicateMovieClip(messaggio, "messaggio" +i, depth);
mess._y=yposition;

coloreLista = new Color(mess);
i%2==0 ? coloreLista.setRGB(0xeeeeee) : coloreLista.setRGB(0xffffff);
delete coloreLista;
mess.ListaIdmessaggio=ListaIdmessaggio_array[i];
mess.ListaDataora=ListaDataora_array[i];
mess.ListaNickname=ListaNickname_array[i];
mess.ListaOggetto=ListaOggetto_array[i];
depth--;
yposition = yposition+25;
}

majin
03-30-2003, 07:43 AM
thanks tg this work perfectly