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
rgarimellaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.