Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Possible to do an actionscript For .. Each Loop?

Status
Not open for further replies.

mattfarley

IS-IT--Management
Dec 11, 2002
25
0
0
US
I have about 70 variables loading into a flash project, they are all named EVS####
(ie: EVS1234, EVS1235, EVS1236, etc)

I want to manipulate each variable coming in. Is there a way to do a for each loop? Here is an example of my current code:

if (_lv.EVS2902 > 0) {
EVS2902.swapdepths(501);
EVS2902.plotter.nextFrame();
EVS2902.plotter.donotremove=true;
}
if (_lv.EVS3110 > 0) {
EVS3110.swapdepths(502);
EVS3110.plotter.nextFrame();
EVS3110.plotter.donotremove=true;
}
if (_lv.EVS3133 > 0) {
EVS3133.swapdepths(503);
EVS3133.plotter.nextFrame();
EVS3133.plotter.donotremove=true;
}
etc
etc
etc

I'd like to just have 1 For Each loop process all the variables. Is this possible?

Thanks!
-Matt
 
what is the structure of the _lv object

does evs whatever have a name an a value?

_______________________________________
You know you're old if you can remember when bacon, eggs and sunshine were good for you
 
I'm trying this:

for (y=500; y<8000; y++){
if ( eval(&quot;_lv.EVS&quot;+y) > 0 ) {
eval(&quot;EVS&quot;+y+&quot;.swapdepths(&quot;+y+&quot;)&quot;);
eval(&quot;EVS&quot;+y+&quot;.plotter.nextFrame();&quot;)
eval(&quot;EVS&quot;+y+&quot;.plotter.donotremove=true&quot;);
}
}

But it isn't working.
 
try putting all evs numbers in an array

evsNums = [2902,3110,..........];
_lv.onLoad = function(){
for(var i =0;i<evsNums.length;i++){
y = eval(&quot;_lv.evs&quot; + evsNums)
if(y>0){
x = &quot;_lv.evs&quot; + evsNums;
x.swapdepths(500 + i);
x.plotter.nextFrame();
x.plotter.donotremove=true;
}
}
}

_______________________________________
You know you're old if you can remember when bacon, eggs and sunshine were good for you
 
Code:
_lv.onLoad = function(){
	for(var i =0;i<evsNums.length;i++){
        y = eval(&quot;_lv.evs&quot; + evsNums[i])
        if(y>0){
			x = &quot;_lv.evs&quot; + evsNums[i];
        x.swapdepths(500 + i);
        x.plotter.nextFrame();
        x.plotter.donotremove=true;
          }
}
}

_______________________________________
You know you're old if you can remember when bacon, eggs and sunshine were good for you
 
ya got it working like this:

numItems = 5000;
startnumber = 2000;

for (i=0; i<=numItems; i++) {
addnumber = startnumber + i;
temp = &quot;EVS&quot; add addnumber;
temp2 = &quot;_lv.EVS&quot; add addnumber;
if (eval(temp2) > 0) {
eval(temp).swapdepths(500+i);
eval(temp).plotter.nextFrame();
eval(temp).plotter.donotremove=true;
}
}

Thanks!
 
Way to go Bill... You finally caught on!

Now maybe a second step? Previewing your posts before posting them!

Regards,

cubalibre2.gif

Bacon, eggs and sunshine are still good for me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top