LOGIN Don't have an account yet?   Register

Forgot password?
 
14Dec2009

duplicateMovieClip in AS3


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! :-)

This post has no comments | Post your comment


Leave a Reply

blog entries RSS Feedproducts RSS Feed

Categories

Popular Files

  • Compact Flash Mp3 Player
  • Horizontal Image Slide on Mouse Move
  • Accordion Menu with Images from XML
  • Accordion Banner Rotator
  • Continuous Image Slider
  • Mp3 Player with Playlist
  • Flash Ken Burns Effect Slideshow
  • Accordion Gallery
  • Horizontal Scroller Slideshow
  • Fade In Fade Out Slideshow With Navigation
  • Simple AS3 Flash Video Player
  • Zoom Gallery

Download the plugin above
Read more about Flabell WordPress plugin

Archives

Search the blog