LOGIN Don't have an account yet?   Register

Forgot password?
 
22Jan2010

duplicateMovieClip and getNextHighestDepth in AS3


For all of us that used AS2 for a long time, we want some things to remain as simple as they were in AS2. So we created our own functions which we use as Prototypes! :-)

duplicateMovieClip

// var mc : MovieClip = mcRating.duplicateMovieClip(new mcStar(), "mcStar" + j);
MovieClip.prototype.duplicateMovieClip = function(obj : *, pName : String = "mcItem") : Object
{
       this[pName] = this.addChild(obj);
       this[pName].name = pName;
       return this[pName];
};

getNextHighestDepth

Make sure that mc is inside mcImages (or whatever movieclip you are using).

// mc.getNextHighestDepth(mcImages);
MovieClip.prototype.getNextHighestDepth = function(scope : Object) : void
{
	scope.setChildIndex(this, (scope.numChildren - 1));
};

Hope this help! :-)

This post has no comments | Post your comment


Leave a Reply