Re: [Flashcoders] as3 creating sprite instances in a loop
I think the issue is that you are waiting until you exit the loop to do any addChild() calls. In that case you will only ever get one sprite added to the display list. This is because when the loop is done it only has a single reference to a sprite. You might want to do two things. First, and most important, add each sprite to an array. Second, call addChild() within the loop. var mySpriteArray:Array = new Array(); for (var j:uint = 0; j _columns; j++) { var sprite:Sprite = new Sprite(); // This will allow you to reference the sprites // later more easily. mySpriteArray.push(sprite); addChild(mySpriteArray[j]); // or addChild(sprite); } Charles P. On Dec 30, 2007 11:23 AM, Matt Muller [EMAIL PROTECTED] wrote: Hi, does anyone know how to create individual sprite instances in a loop for (var j:uint = 0; j _columns; j++) { var sprite:Sprite = new Sprite(); } this just over writes the sprite. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] as3 creating sprite instances in a loop
Hi, does anyone know how to create individual sprite instances in a loop for (var j:uint = 0; j _columns; j++) { var sprite:Sprite = new Sprite(); } this just over writes the sprite. thanks MaTT ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] as3 creating sprite instances in a loop
I'm not quite sure if I understand your question fully but I think the problem you're having is that you need to do something with them - for example if you pushed each new sprite into an array then you'd have a reference to each of them, but the you're doing it at the moment you'll just lose the reference to the old one each time. Piers On 30 Dec 2007, at 16:23, Matt Muller wrote: Hi, does anyone know how to create individual sprite instances in a loop for (var j:uint = 0; j _columns; j++) { var sprite:Sprite = new Sprite(); } this just over writes the sprite. thanks MaTT ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] as3 creating sprite instances in a loop
and, of course, you can't forget addChild(). []'s andrei On Dec 30, 2007 2:50 PM, Piers Cowburn [EMAIL PROTECTED] wrote: I'm not quite sure if I understand your question fully but I think the problem you're having is that you need to do something with them - for example if you pushed each new sprite into an array then you'd have a reference to each of them, but the you're doing it at the moment you'll just lose the reference to the old one each time. Piers On 30 Dec 2007, at 16:23, Matt Muller wrote: Hi, does anyone know how to create individual sprite instances in a loop for (var j:uint = 0; j _columns; j++) { var sprite:Sprite = new Sprite(); } this just over writes the sprite. thanks MaTT ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders