header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
khze86
Points:180
Posts:8
Answered

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......



Terry
Points: 0
Posts:0
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();
} 


khze86
Points: 180
Posts:8
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.....

Terry
Points: 0
Posts:0
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;
}



fresh
Points: 0
Posts:0
Accepted Answer
2/19/2010 3:39:25 AM








var object:Array=new Array();

for (var i:int=0;i<=100;i++) 
{ 
    object[i] = "Obj"+i
}


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 0+7 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions