I'm coming from AS2 and having trouble converting to AS3. I'm trying to make an exploding particle using a movie clip but keep running into errors.
Here's the original AS2 script:
maxparticles = 200; //number of particles
i = 0; //counter, for "while" loop
while(i < maxparticles){
newparticlename = "particle" + i; //creates a new name for a new particle instance
particle.duplicateMovieClip(newparticlename, i); //duplicates our particle mc
i++;
}
And here's my converted AS3 script:
var maxparticles = 200; //number of particles
var i = 0; //counter, for "while" loop
while(i < maxparticles){
var newparticlename = "particle" + i; //creates a new name for a new particle instance
particle.duplicateMovieClip(newparticlename, i); //duplicates our particle mc
i++;
}
I keep getting problems here here:
particle.duplicateMovieClip(newparticlename, i);
Any help is greatly appreciated.
AS3 does things a bit differently. There is no such method as duplicateMovieClip and there's no such concept. AS3 manipulates the visual objects (MovieClips, Shapes, etc.) in a more object way: you can create and destroy them, you can keep them in memory to save for later, you can detach them from their respective parents and re-attach them somewhere else.
In order to create multiple instances of the same object you do as the following:
(please also keep in mind it wasn't tested, but the concept should be right)