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

[tabcontent]
<span style="color: #993300;">MovieClip</span>.<span style="color: #000087;">prototype</span>.swapClip = <span style="color: #993300;">function</span>(idName) {
        <span style="color: #993300;">var</span> obj = {
                <span style="color: #000087;">_x</span>:<span style="color: #993300;">this</span>.<span style="color: #000087;">_x</span>,
                <span style="color: #000087;">_y</span>:<span style="color: #993300;">this</span>.<span style="color: #000087;">_y</span>,
                <span style="color: #000087;">_xscale</span>:<span style="color: #993300;">this</span>.<span style="color: #000087;">_xscale</span>,
                <span style="color: #000087;">_yscale</span>:<span style="color: #993300;">this</span>.<span style="color: #000087;">_yscale</span>,
                <span style="color: #000087;">_rotation</span>:<span style="color: #993300;">this</span>.<span style="color: #000087;">_rotation</span>,
                <span style="color: #000087;">_visible</span>:<span style="color: #993300;">this</span>.<span style="color: #000087;">_visible</span>,
                <span style="color: #000087;">_alpha</span>:<span style="color: #993300;">this</span>.<span style="color: #000087;">_alpha</span>,
                idName:idName
              };
        <span style="color: #993300;">this</span>.<span style="color: #000087;">_parent</span>.<span style="color: #000087;">attachMovie</span>(idName, <span style="color: #993300;">this</span>.<span style="color: #000087;">_name</span>, <span style="color: #993300;">this</span>.<span style="color: #000087;">getDepth</span>(), obj);
}
<span style="color: #000087;">ASSetPropFlags</span>(<span style="color: #993300;">MovieClip</span>.<span style="color: #000087;">prototype</span>, ["<span style="color: blue;">swapClip</span>"], 1);
[/tabcontent]
Usage:
[tabcontent]
my_mc.swapClip("<span style="color: blue;">MyLinkageID</span>");
<span style="color: #878787;">//MovieClip instance named my_mc will be replaced by another clip.
</span></pre>
[/tabcontent]