?
Solved

USING EVAL IN LOOP

Posted on 2004-08-24
2
Medium Priority
?
226 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 375 total points
ID: 11889916
why do you want to loop it?
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
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…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to record live broadcast.
Suggested Courses

777 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