PDA

View Full Version : Concatinating dynamic variable names


kennethpardue
02-10-2003, 04:26 PM
I'm having trouble getting a dynamic variable to print right. What's wrong with this method (the "i" below will be a number passed through a function)?

nav_btn_1.nav_btn_name="MyButtonName"

i=1;


trace (this["nav_btn_"+i+".nav_btn_name"]);
-- I get 'undefined' returned

or

trace (["nav_btn_"+i+".nav_btn_name"]);
-- I get the literal 'nav_btn_1.nav_btn_name' returned instead of MyButtonName

CyanBlue
02-10-2003, 11:50 PM
Howdy...

Try this...

trace(this["nav_btn_" + i].nav_btn_name);

kennethpardue
02-11-2003, 06:29 PM
Yup, that did it! Thanks kindly VERY much. Boy that sure made everything easier, now I have most of my code automating what I need it to do.

Thanks again!

Kenneth