Solved

USING EVAL IN LOOP

Posted on 2004-08-24
2
182 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
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.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

747 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

12 Experts available now in Live!

Get 1:1 Help Now