or rather addChildAt(instance, i);
Main Topics
Browse All Topics Dear Experts,
I'm using code below to create multiple instances of a MovieClip called mc.
The problem is that every time the new mc gets added to the display list it replaces the one created before.
How do I get around this problem?
I know I could get around it by avoiding the use of the Array, but my project needs to reference the Array to know which MovieClip to load.
PS: I've just started learning AS3, I used to do this using the attachMovie() method.
Advice on good study books/tutorials are welcome as well.
regards,
dreamMonkey
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi Blue,
Thanks for your suggestion, unfortunately it doesn't seem to do the job.
The problem is, I think, that every time I add the Child I reference the same MovieClip.
So the one created before gets removed (or moved) to the new .x position of the same container.
Basically this function is merely moving 1 MovieClip around the stage instead of dynamically creating multiple instances of the clip.
Maybe I'm going at this the wrong way.
But I need a solid way to do this in my project.
Any ideas?
regards,
dreamMonkey
OK, I see what you mean, trouble is my Array looks like this :
varA:Array = new Array();
A.push(new mc1());
A.push(new mc2());
A.push(new mc3());
// and so on ...
I'm using the Array to find out what mc should be added .
I guess this is getting a little bit to abstract ...
--> allow me : I'm actually rewriting the code done in AS2 to AS3 for this project :
http://www.jazz-band.be/dM
I need to know what Tile fits and which does not. I can actually let flash generate a terrain where the roads in all the tiles match, but then I have to create a new instance of that tile. I thought best way to do this is using an Array...
Blue, thanks for your help, I'll get back to this thread later because I have to start celebrating New Year's eve, (for some reason...)
Best Wishes !
dreamMonkey
I don't see any reason why this array would be starting at 1, the switch statement looks like a better solution for getting the MC's on the stage.
try doing this in the addToArray()
trace(A.length);
instead of
trace(A[1]);
also:
A.push(ins);
should probably not be hanging out in between the functions, it is out of the scope of where ins is created.
OK, I forgot about the A.push(ins)... should 've been deleted... that's why A[0] is currently null ...
silly me...
Thanks for your suggestion ESchleep !
I think I'll manage from here,
won't be a few days before I do (and close the question though ...)
Best wishes !
d
PS; the reason why I 'm converting this movie into AS3 is mainly because I have to learn the new AS3,
but also to get better performance, any suggestion are welcome (in regard to the URL posted earlier...)
Business Accounts
Answer for Membership
by: blue-geniePosted on 2008-12-31 at 06:11:59ID: 23269888
use addChildAt(i, instance)