Your code does what you're asking but I suspect you're having trouble with the positioning, or something similar. Since DC has no initial y, all instances will end up at 30, using the code below.
Here's an adaptation that shows two visual results: position and trace, using the instance name request you mentioned. Note that, when adding an instance name programmatically, you can't refer that instance by name the same way you can when creating the instance name in the IDE. You must use getChildByName() instead. var dataLength:int = 5; for(var i = 0; i<dataLength; i++) { var DC:DataCard = new DataCard(); DC.x = Math.random()*550; DC.y = Math.random()*400; DC.name = "dataCard" + i; addChild(DC); trace(getChildByName("dataCard"+i).name); } Rich > In AS3 I tried the follwoing > > for(var i = 0; i<dataLength; i++) { > var DC:DataCard = new DataCard(); > DC.y += 30; > } > > What comes up is an only one instance of the movieClip as in one replaces > the one before. > > Is there another way to achieve this? How can I add instance name to the > MovieClip using the i from the loop? _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders