Wednesday, March 16, 2011

3D actionscript objects to bitmaps example

Here's a quick post on how to convert your 3d spark component into a bitmap for use with the drag manager. I'm not going to wax poetic about this , if anyone want's further explanation please let me know and I'd be happy to go into details.

The dice object here is a 3D skinnable component. In order to keep the perspective
the same when converting it to bitmapData, you need to have your perspectiveProjection properly set.

var ds:DragSource = new DragSource();
dice.transform.perspectiveProjection = new PerspectiveProjection();
dice.transform.perspectiveProjection.projectionCenter = new Point(400,220);
dice.transform.perspectiveProjection.fieldOfView = 10
var bitmapData:BitmapData = BitmapUtil.getSnapshot(dice);
var bitmap:Bitmap = new Bitmap(bitmapData);
var snap:Image = new Image();
snap.width = 80;
snap.height = 80;

I ended up not even using the drag manager in the application this is from, but the research it took to get this far was too good to forget.

No comments:

Post a Comment