PDA

View Full Version : Dynamic Object Selection


Dark_Element
09-12-2004, 02:39 AM
is there a way to target a object with a name that may vary depending on a value?

note: the variable's range is so large that a switch/if+else if statement couldnt possibly get it.

eg: i want to select a object with a name of "foo"+bar and that "bar" may be different everytime. In addition that bar may be from 1 to 99999.

devonair
09-12-2004, 08:03 AM
hey, Dark_Element,

the basic format is to use the target path to the object, no dot, some square brackets containing the object name in quotes, a plus operator and your variable name, then a dot and the property you're trying to access..

so what all that boils down to is this, as an example:

this._parent["foo"+bar]._alpha

hope that made some sense and helps..

d.