2/3/2010 3:52:28 AM
Title:
Declare new Object
Hi
I wanted to create 100 objects.
Instead of typing
obj1 = new Object();
obj2 = new Object();
obj3 = new Object();.....
However when i use for loop...
for (var i=1;i<=100;i++) {
obj+i=new Object();
}
there is error in the above code. May i know how to correct this?
Thanks......
2/3/2010 5:34:45 AM
Use it like this
for (var i=1;i<=100;i++) {
var Obj="Obj"+i;
var i =new Object();
}
2/3/2010 6:29:05 PM
hi terry
i still couldnt get it.. there is still error.. could u explain the above codes?
thanks.....
2/3/2010 11:12:23 PM
Sorry I forget to call the method so it didn't gave me error, this is the fixed one have tested in Flash Builder with actionscript 3. This works perfect and creates the Objects as you want
Obj1
Obj2
Obj3.....
for (var i:int=1;i<=100;i++) {
var Obj:Object="Obj"+i;
}
2/19/2010 3:39:25 AM
var object:Array=new Array();
for (var i:int=0;i<=100;i++)
{
object[i] = "Obj"+i
}