actionscript 3 - flash as3 dynamic instance variable name / concatenation -
i have array of project type codes this:
project_types_array[0] = "p" project_types_array[1] = "exp"
etc.
and corresponding set of movie clips, exported actionscript, names:
type_p type_exp
etc.
i want somehow dynamically attach movieclip on stage according project type exists in array. this:
for ( var in project_types_array) { if (project_types_array[i] == "p"){ var clip_p = new type_p(); container.header.type_loader.addchild(clip_p); } }
but i'd rather this:
for ( var in project_types_array) {
var "clip_" + project_types_array[i] = new "type_" + project_types_array[i](); container.header.type_loader.addchild("clip_"+project_types_array[i]);
}
how achieve this?
try
var c:class = getdefinitionbyname('type_' + project_types_array[i]); var spr:c = new c();
Comments
Post a Comment