Solved

USING EVAL IN LOOP

Posted on 2004-08-24
2
192 Views
Last Modified: 2010-04-03
How do I code the following case statements in loop (for next). I tried
eval("myCO"+i) = new Color(eval("lot_"+i)). IT DID NOT WORK

switch (i) {
                  case 0 :
                    myCO0 = new Color(lot_0);
                    break;
                  case 1 :
                    myCO1 = new Color(lot_1);
                    break;
                  case 2 :
                    myCO2 = new Color(lot_2);
                    break;
                  case 3 :
                    myCO3 = new Color(lot_3);
                    break;
                  case 4 :
                    myCO4 = new Color(lot_4);
                    break;
                  case 5 :
                    myCO5 = new Color(lot_5);
                    break;
                  case 6 :
                    myCO6 = new Color(lot_6);
                   break;
                  }
0
Comment
Question by:amiteshsinha
2 Comments
 
LVL 10

Expert Comment

by:muso120999
ID: 11884968
Can you not use something like:
this["myCO"+i] = new Color(this["lot_"+i]);

"this" might have to be substituted for the container object.

I think the eval you are using just returns the value of the variable, rather than the variable itself.

I don't know the code you are using, but I think I would be tempted to use Arrays anyway.
0
 
LVL 39

Accepted Solution

by:
blue-genie earned 125 total points
ID: 11889916
why do you want to loop it?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now