Solved

USING EVAL IN LOOP

Posted on 2004-08-24
2
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can't see Flash on IE Windows Apps - Windows 8.1 4 409
Youtube video error 30 841
Rotating Adobe pdf document 4 330
Windows 7, Adobe Flash Player and Internet Explorer 11 15 105
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
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.

733 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