Search code examples
flashactionscript-3clonebulkloader

Clone movieclip in ActionScript3



I'm using BulkLoader to load MovieClips and Bitmaps into my AS3 app. Bitmaps are easy to clone, but I have some problems with complicated MovieClips, which has many children, buttons, symbols, etc.
I've found many ways to clone MovieClips as Bitmaps, but is there a way to clone it as MovieClip, with all its attributes?


Solution

  • there are 2 ways :

    You can copy Loader :

    var newLoader:Loader = new Loader();
    newLoader.loadBytes(oldLoader.contentLoaderInfo.bytes);
    

    or You can get MovieClip class and create new instance of it . But for this You will have to compile external SWF with some document class (You dont have to create .as file , just type there some namespace for this SWF)

    var movieType:Class = myMovieClip.constructor;
    var copyMovie:MovieClip = new movieType();