Duplicating movie clips in AS3
Say I have a movieclip called mcLoader a开发者_如何学编程nd within it I have some loaded bitmap image (don't know the name, it's dynamically loaded).
How do I copy that bitmap image into a movieclip mcContainer?
The following code will copy every content of mcLoader and put it in mcContainer:
import flash.display.BitmapData;
import flash.display.Bitmap;
for (var i:int = 0; i < mcLoader.numChildren; i++)
{
var obj = mcLoader.getChildAt(i);
var bmd:BitmapData = new BitmapData(obj.width, obj.height);
var bm:Bitmap = new Bitmap(bmd);
bmd.draw(obj);
mcContainer.addChild(bm);
}
精彩评论