rgarimella
asked on
Dynamic Variables
Hi,
How do I assign dynamic variables in a loop??
q1Answered = 0
q2Answered = 0
var frameArray = [320, 1260, 1700, 2211, 2810]
for (var i = 0; i<frameArray.length; i++){
if ((frameArray[i] == vdload._currentframe) && (Q[i+1]+Answered == 0)){
_parent.popup.gotoAndPlay( "L"+[i+1]+ "_Incorrec t");
vdload.stop();
q[i+1]+Answered = 1;
}
}
In this case the popup does not fire up. But if it is written as Q1Answered == 0 and q1Answered = 1;then the popup fires up.
Any ideas
How do I assign dynamic variables in a loop??
q1Answered = 0
q2Answered = 0
var frameArray = [320, 1260, 1700, 2211, 2810]
for (var i = 0; i<frameArray.length; i++){
if ((frameArray[i] == vdload._currentframe) && (Q[i+1]+Answered == 0)){
_parent.popup.gotoAndPlay(
vdload.stop();
q[i+1]+Answered = 1;
}
}
In this case the popup does not fire up. But if it is written as Q1Answered == 0 and q1Answered = 1;then the popup fires up.
Any ideas
for the Q[i+1]+Answered instead do _root["Q"+(i+1) + "Answered"]
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
In This case both the answers do not work
Okay, firstly it is case sensitive, so you will need to use "q" rather than "Q". Secondly, I don't know where your loop resides, so try my code with _root rather than this (as in Drakkin's suggestion)...
ASKER
Oops you are right
It was case sensitive
Thanks
My bad
It was case sensitive
Thanks
My bad