Actionscript 2.0, Flash, Flash _, Web developer

Duplicate MovieClip with BitmapData

Simple and usefull function to get you going with duplicating mc with dynamiclly loaded JPEG which doesn’t work. it duplicates MovieClip but without JPEG

so use bitmap to duplicate those type of mc’s and here is a solution
ActionScript Code:
import flash.display.*;
function duplicateMC(mc:MovieClip, mc2:MovieClip) {
mcBMP = new BitmapData(mc._width, mc._height, false, 0x00FFFFFF);
mc2.attachBitmap(mcBMP, this.getNextHighestDepth());


20 thoughts on “Duplicate MovieClip with BitmapData

  1. Hi,
    Maybe just me who is stupid… But i cant get it working. I tried this…

    var ref = _root.createEmptyMovieClip(“img_mc1”, 1);
    loader.loadClip(“http://localhost/images/file.jpg”, ref);

    smileyface.onPress = function () {
    duplicateMC(this, “blab”)
    blab.startDrag(); // cannot drag
    trace(blab); // says “undefined”

    // Your code here…

  2. it copies pixel data (bitmap data) of the movieclip, so no interaction remains, only image based on pixels
    as I’ve said this is important for dynamiclly loaded JPEG’s but can help in other sitautions as well

  3. Andrew says:

    The display class doesn’t seem to have been included with my copy of Flash MX. Any suggestions on where to download this from?

  4. Jason Sawtelle says:

    Yes!!!! Thanks a lot. Works like a charm, and so easy to integrate. Here’s my modded and commented code for others to use. All you need to add is the external JPG and the btn.


    import flash.display.*;

    function duplicateMC(mc1:MovieClip, mc2:MovieClip) {
    var bmpData = new BitmapData(mc1._width, mc1._height, false, 0x00ffffff);

    // create initial mc to load external asset
    // create the next mc to hold the duplicate of the first mc
    // move the duplicate mc so its not directly on top of the original
    // your stage will need to be big enough to accommodate
    // wherever you move it
    my_mc2._x = 300;

    // load the external asset into the first mc

    // do it! don’t forget to make this btn mc on the stage
    my_btn.onRelease = function() {

  5. P.Svilans says:


    I’ve been REALLY pulling my hair over a problem:
    I need to copy a movieclip into a bitmapData, BUT, this movieclip is created using createEmptyMovieclip, and then modified using lineTo and fills and such. BitmapData’s.draw function doesn’t allow copying a movieclip with on stage transformations…and suggestions going around this besides copying pixel for pixel?



  6. P.Svilans says:

    I’m using myMc.lineTo functions, with myMc.beginGradientFill() and related functions. So far the only way I’ve been able to get it to work is actually using the Movieclips class duplicateMovieClip function before drawing it on to my bitmapData…

  7. updated for as3~

    public function cloneMovieClip(original:MovieClip, clone:MovieClip)
    var tempData = new BitmapData(original.width, original.height, false, 0xffffff);
    var tempBitmap:Bitmap = new Bitmap(tempData);

  8. My programmer is trying to convince me to move to .net from PHP.
    I have always disliked the idea because of the expenses.
    But he’s tryiong none the less. I’ve been using WordPress on several websites for about a year and am concerned about switching to another platform.
    I have heard good things about Is there a way I can transfer all my wordpress content into it?

    Any kind of help would be really appreciated!

  9. Pingback: bild laden-per mausklick duplizieren - Flashforum

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s