Posted on 2004-08-24
Medium Priority
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);
                  case 1 :
                    myCO1 = new Color(lot_1);
                  case 2 :
                    myCO2 = new Color(lot_2);
                  case 3 :
                    myCO3 = new Color(lot_3);
                  case 4 :
                    myCO4 = new Color(lot_4);
                  case 5 :
                    myCO5 = new Color(lot_5);
                  case 6 :
                    myCO6 = new Color(lot_6);
Question by:amiteshsinha
LVL 10

Expert Comment

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.
LVL 39

Accepted Solution

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

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

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.

Join & Write a Comment

In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
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 how to load their YouTube profile onto Flash Media Live Encoder.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

607 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