setting i = var rather than number
in
Programming Questions
•
6 months ago
I want to set my index to a variable rather than a name in my sketch. because further up im doing this:
//random first video at program start
int fL = int(random(0, 5));
int fR = int(random(0, 5));
int eL = int(random(0, 5));
int eR = int(random(0, 5));
int mL = int(random(0, 5));
int mR = int(random(0, 5));
and it is used for this:
//play chosen index
foreheadLeft[fL].play();
foreheadRight[fR].play();
eyesLeft[eL].play();
eyesRight[eR].play();
mouthLeft[mL].play();
mouthRight[mR].play();
then affected by user with mouseclick i want it to increment now but from originally chosen video:
if (mouseX < cLineX && mouseY < tLineY) {
for (int i = fL; i < topLeftVid.length; i++) {
foreheadLeft[i] = new Movie(this, topLeftVid[i]);
foreheadLeft[i-1].pause();
foreheadLeft[i].play();
foreheadLeft[i].loop();
}
fill(255);
ellipse(mouseX, mouseY, 10, 10);
}
the error is "cannot find anything named "fL"
how do i get the program to get that value from somewhere in the sketch?
thanks for you help!
//random first video at program start
int fL = int(random(0, 5));
int fR = int(random(0, 5));
int eL = int(random(0, 5));
int eR = int(random(0, 5));
int mL = int(random(0, 5));
int mR = int(random(0, 5));
and it is used for this:
//play chosen index
foreheadLeft[fL].play();
foreheadRight[fR].play();
eyesLeft[eL].play();
eyesRight[eR].play();
mouthLeft[mL].play();
mouthRight[mR].play();
then affected by user with mouseclick i want it to increment now but from originally chosen video:
if (mouseX < cLineX && mouseY < tLineY) {
for (int i = fL; i < topLeftVid.length; i++) {
foreheadLeft[i] = new Movie(this, topLeftVid[i]);
foreheadLeft[i-1].pause();
foreheadLeft[i].play();
foreheadLeft[i].loop();
}
fill(255);
ellipse(mouseX, mouseY, 10, 10);
}
the error is "cannot find anything named "fL"
how do i get the program to get that value from somewhere in the sketch?
thanks for you help!
1