If you used AS2, you probably loved the way duplicating movieclips worked. We did too! :-)
We created this prototype function so that you can easily use the same technique in AS3:
// Duplicate movieclips in AS3
MovieClip.prototype.duplicateMovieClip = function(obj : *, pName : String) : Object
{
this[pName] = this.addChild(obj);
this[pName].name = pName;
return this[pName];
};
This is how you call this function:
for(var i : uint = 0; i < nrStars; i++)
{
var mc : MovieClip = mcRating.duplicateMovieClip(new mcStar(), "mcItem" + i);
trace(mcRating["mcItem" + i].name);
mc.x = i * mcRating.mcStar.width;
}
mcRating - is the movieclip where the stars appear
mcStar - is the linked movieclip in the library, with the name mcStar
"mcItem" + i - is the name of each duplicated MovieClip.
In the example above I'm assuming you have a variable that holds the number of stars, and that you want to place each star near the previous one.
Any questions, let us know! Enjoy! :-)