When we need to replace a movie clip on stage with another with a Linkage ID the following code will be useful.

[cc lang=”actionscript3″] MovieClip.prototype.swapClip = function(idName) { var obj = { _x:this._x, _y:this._y, _xscale:this._xscale, _yscale:this._yscale, _rotation:this._rotation, _visible:this._visible, _alpha:this._alpha, idName:idName }; this._parent.attachMovie(idName, this._name, this.getDepth(), obj); } ASSetPropFlags(MovieClip.prototype, [“swapClip“], 1); [/cc]

Usage:
[cc lang=”actionscript3″] my_mc.swapClip(“MyLinkageID“); //MovieClip instance named my_mc will be replaced by another clip.

[/cc]