is it possible to do something like the following?
basically to createCode:for (var i=0; i<variableAmt; i++) {
var ["temp" + [i]] = new Object();
}
temp0, temp1, temp2, etc... until it reaches the variable amount?
thanks in advance,
ChaseNYC
Printable View
is it possible to do something like the following?
basically to createCode:for (var i=0; i<variableAmt; i++) {
var ["temp" + [i]] = new Object();
}
temp0, temp1, temp2, etc... until it reaches the variable amount?
thanks in advance,
ChaseNYC
Yup. I do it all the time.Quote:
Originally Posted by ChaseNYC
d.
ummm would you care to enlighten me?
double post... ****ty comp...
Well, it depends on what you are trying to do. You can create a series of objects in an array like this:
Or you can create a series of movie clips, say like you were creating a dynamic menu;Code:var myArray:Array = new Array();
for (var i = 0 ; i < n , i++){
myArray[i] = new Object();
//put a bunch of variable stuff in the new object here;
}
Ultimately, by saying something like:Code:var menu:MovieClip;
for(var i = 0 ; i < n ; i++){
var clip:MovieClip = menu.createEmptyMovieClip(i + "_submenu", i);
//or alternatively you could attach a movie, or add a class here;
}
var ["temp" + [i]] = new Object();
You are creating object that are named:
temp1
temp2
temp3
etc.
You can later refer to them by name directly, or through a loop again. Personally, I usually put everything in to an array just so I have them all in one place.
If you have a more specifici question, I'd be happy to try and answer in more detail.
Hope this helps.
d.