• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

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]+"_Incorrect");
                 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
0
rgarimella
Asked:
rgarimella
  • 2
  • 2
1 Solution
 
DrakkonCommented:
for the Q[i+1]+Answered instead do _root["Q"+(i+1) + "Answered"]
0
 
muso120999Commented:
try:

         for (var i = 0; i<frameArray.length; i++){
          if ((frameArray[i] == vdload._currentframe) && (this["q"+(i+1)+"Answered"] == 0)){
               _parent.popup.gotoAndPlay("L"+(i+1)+"_Incorrect");
                 vdload.stop();
                          this["q"+(i+1)+"Answered"] = 1;
                }
           }
0
 
rgarimellaAuthor Commented:
In This case both the answers do not work

0
 
muso120999Commented:
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)...
0
 
rgarimellaAuthor Commented:
Oops you are right

It was case sensitive

Thanks
My bad
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now