BitmapData.draw() + registration point problem solved!

Posted by Fourneau Brecht | Posted in Development | Posted on 31-10-2008

1

I’ve been having this nasty problem with BitmapData, I wanted to make a copy of a MovieClip to use it as a reflection of the original MovieClip. This is easy ofcourse using the BitmapData.draw() function. But this only works for MovieClips with the registration point in the top left corner, the draw() method only draws positive data. I found this to be a real pain in the ass because the registration point needed to be in the center for my animations to work good. And halleluja, I found a solution! Using a matrix object I changed the area the draw method should draw into the whole MovieClip. Here’s my code:

var bmd:BitmapData = new BitmapData(my_mc.width,my_mc.height,true,0xFFFFFF);

var m:Matrix = new Matrix();

m.translate(my_mc.width/2,my_mc.height/2);

bmd.draw(my_mc,m);

var bitmap:Bitmap = new Bitmap(bmd);

addChild(bitmap);

I hope I helped some of you with this, because I didn’t really read a good solution on the internet for this problem. If you have any questions, just e-mail me at: mail@brechtfourneau.be

Currently working very hard on my portfolio, I hope I can show it to you all quickly :) (if anyone ever really reads this)

See you.