|
Author |
Topic: how do i do this in a for loop? (Read 845 times) |
|
Master64
|
how do i do this in a for loop?
« on: Nov 15th, 2003, 9:34pm » |
|
Hoi I want to make a 100 objects with a for loop. I have a working class. I know Flash AS very well so i was thinking i would do this some thing like this: Star ["star"+i] = new Star(); but it's not working. I have been looking in de reference for the right Syntax but with no luck. i hope this is clear thanx M64
|
|
|
|
Jerronimo
|
Re: how do i do this in a for loop?
« Reply #1 on: Nov 16th, 2003, 2:45am » |
|
probably need something like this: Code: // first, declare the array int nItems = 100; myClass items[] = new myClass[ nItems ]; void setup() { // allocate all of the individual items for( int i=0 ; i<nItems ; i++ ) { items[ i ] = new myClass(); } } class myClass { ... } |
|
|
|
|
|
Master64
|
Re: how do i do this in a for loop?
« Reply #2 on: Nov 16th, 2003, 11:37am » |
|
Yeah that's it
|
|
|
|
Jerronimo
|
Re: how do i do this in a for loop?
« Reply #3 on: Nov 17th, 2003, 1:06am » |
|
No prob.
|
|
|
|
|