|
Author |
Topic: easy question (Read 1130 times) |
|
beachmeat
|
easy question
« on: Jul 24th, 2003, 4:55pm » |
|
How can I address multiple instances dynamic like this: for(int i=0; i<10; i++) { ["instance" + i].draw(); // fictive } I habe 10 instances instance1, instance2 etc. and want to call the method draw without adressing all of them explicit
|
|
|
|
toxi
|
Re: easy question
« Reply #1 on: Jul 24th, 2003, 5:51pm » |
|
the mark of an actionscript user... hi, the best way to deal with multiple objects is to store their references in an array (this is btw. also true for actionscript): Code:int numObjects=10; Object[] myObjects = new Object[numObjects]; // building instances and storing references for(int i=0; i<numObjects; i++) { myObjects[i]=new TestCase(whatever); } // retrieving & using instances for(int i=0; i<numObjects; i++) myObjects[i].draw(); |
|
|
http://toxi.co.uk/
|
|
|
beachmeat
|
Re: easy question
« Reply #2 on: Jul 24th, 2003, 5:56pm » |
|
Good eye on the code-origin In AS I do it that way too, I was just wondering if there is any possibility to do it like eval("str" + i) or scope["str" + i]... Thx! Btw: Like your site very much...You from Germany eh? "Karsten Schmidt" it says Same here
|
« Last Edit: Jul 24th, 2003, 6:02pm by beachmeat » |
|
|
|
|
|