all groups > flash actionscript > april 2004 >
You're in the

flash actionscript

group:

Dynamic Variable naming



Dynamic Variable naming QuantumDynamix
4/3/2004 10:21:20 PM
flash actionscript: I have created a loop that parses an array, to create a new variable for each
object in the array. I have most of the code written, but I'm not sure how to
have flash create dynamic variable names. Below is an example of the code:

i=1
do {
item+i = productList.pop()
i=i+1
}while (productList.length <> 0)

the "item+1" is the part I can't figure out. What do I write to have it
recognive that as a variable name?

I tried to search to forum before posting this, but didn't find anything.

Thanks
Re: Dynamic Variable naming siderius
4/4/2004 12:40:56 AM
Hey QD,

try this:

set ("image"+i, productList.pop());

Re: Dynamic Variable naming Maverick_01
4/6/2004 2:45:02 PM
Okay, that seemed to work, but how do I apply it to the code below,
specifically for the two lines of code that creates the new object and
assigns information to it.

do{
set("item"+i+"Array", productList.slice(r, r+6))
set(_root+"item"+i, new Object())
set(_root+"item"+i+".prodNo", "item"+i+"Array[0]")
r=r+6
i=i+1
}while (r<prodListLength)

Thanks



[quoted text, click to view]

AddThis Social Bookmark Button