This content has been marked as final. Show 6 replies
are you trying to create several instances of one class or one instance from each of usedNo.length classes?
"are you trying to create several instances of one class or one instance from each of usedNo.length classes?" - I am trying to create several instances of subclasses of MissingGameObjects class. Subclass name evaluaion is working if i put them in variables with declared names. Now I am trying to put this new subclass instances to several variables which is already declared by evaluating the variable names. I want to evaluate these variable names i.e.
public var missing1_mc:MissingGameObjects;
public var missing2_mc:MissingGameObjects;
public var missing3_mc:MissingGameObjects;
public var missing4_mc:MissingGameObjects;
in a loop (eg. "missing"+ (i +1) + "_mc" in the loop).
I dont want to use missing1_mc , then missing2_mc and so on..I want to evaluate them by "missing"+ (i +1) + "_mc" in a loop. Thanks in advance.
Any reason an array of references wouldn't be more ideal?
if you're trying to use variable object names and variable classes, you can use the following (assuming everything's defined):
Thanks. This can be a way to do it. Alternate way can be as follows :
var missingObjects:Array = new Array();
missing_obj = main_obj + "_" + usedNo + "_x";
ClassReference = getDefinitionByName(missing_obj) as Class;
missingObjects = new ClassReference();