Search code examples
actionscript-3flash-cs4

How to capture current frame from a MovieClip into a BitmapData object?


The movieclip is in a seperate swf file that has been imported into the library. The movieclip itself plays fine (the movieclip is vector based) but when I try and capture the current frame from it into a bitmapdata object nothing seems to happen. I'm wondering if it's some type of security issue?

mc is the movieclip
bitmap=new BitmapData(mc.width,mc.height,false);
trace("Creating bitmap for frame grab width=",mc.width,"height=",mc.height);
bitmap.floodFill(0,0,0xff0000);     //for debugging only
bitmap.draw(mc);

After using the code above to capture the current frame of the movie the texture is solid red so it seems that it is not being changed after the floodfill command I put above for debugging.


Solution

  • Figured it out, the image is being drawn but is off the right of the screen since it seems to be using some sort of centerpoint or offset position to draw the movie. If I allocate the bitmap to be 4x taller and 4x wider then I see the bitmap.