Xinos
27 Apr 2007, 12:42
I've got a rather uggly bit of code here and I'd like to clean up. Right now it's hard coded and would have to be made longer and longer if I add more cards. I've tried to get this loop work nicely but there's too much going on so I get lost and confused allong the way ;P
function sortCards() {
//Associates 10 picture frames with the different cards.
for (i=0; i<20; i++) {
if (pictureNum[i] == 1 || pictureNum[i] == 2) {
frame = 2;
} else if (pictureNum[i] == 3 || pictureNum[i] == 4) {
frame = 3;
} else if (pictureNum[i] == 5 || pictureNum[i] == 6) {
frame = 4;
} else if (pictureNum[i] == 7 || pictureNum[i] == 8) {
frame = 5;
} else if (pictureNum[i] == 9 || pictureNum[i] == 10) {
frame = 6;
} else if (pictureNum[i] == 11 || pictureNum[i] == 12) {
frame = 7;
} else if (pictureNum[i] == 13 || pictureNum[i] == 14) {
frame = 8;
} else if (pictureNum[i] == 15 || pictureNum[i] == 16) {
frame = 9;
} else if (pictureNum[i] == 17 || pictureNum[i] == 18) {
frame = 10;
} else if (pictureNum[i] == 19 || pictureNum[i] == 20) {
frame = 11;
}
_root["card"+i].pictureNum = frame;
}
}
function sortCards() {
//Associates 10 picture frames with the different cards.
for (i=0; i<20; i++) {
if (pictureNum[i] == 1 || pictureNum[i] == 2) {
frame = 2;
} else if (pictureNum[i] == 3 || pictureNum[i] == 4) {
frame = 3;
} else if (pictureNum[i] == 5 || pictureNum[i] == 6) {
frame = 4;
} else if (pictureNum[i] == 7 || pictureNum[i] == 8) {
frame = 5;
} else if (pictureNum[i] == 9 || pictureNum[i] == 10) {
frame = 6;
} else if (pictureNum[i] == 11 || pictureNum[i] == 12) {
frame = 7;
} else if (pictureNum[i] == 13 || pictureNum[i] == 14) {
frame = 8;
} else if (pictureNum[i] == 15 || pictureNum[i] == 16) {
frame = 9;
} else if (pictureNum[i] == 17 || pictureNum[i] == 18) {
frame = 10;
} else if (pictureNum[i] == 19 || pictureNum[i] == 20) {
frame = 11;
}
_root["card"+i].pictureNum = frame;
}
}