Answer the question
In order to leave comments, you need to log in
How to add a different class each time?
Hello.
I have multiple classes Box, Box1, Box2, Box3 ... Box10.
I want to add these classes to the stage randomly using a loop.
for(var i = 0; i < col; i++){
generator = Math.floor(Math.random()*10);
box[i]=new Box+generator();
addChild(box[i]);
}
Answer the question
In order to leave comments, you need to log in
For example, make the CreateInstance(generator) method
And inside it, make a switch case returning objects of various types.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question