1

I have a sprite that contains overlapping shapes. The sprite itself will have it's alpha set to .5, so I have to set the sprite's blendmode to "layer" to keep the overlapping parts from looking transparent with each other. In this screenshot taken from here, it's supposed to look like the one on the right.

enter image description here

Now I want to draw a bitmapData from my sprite, but I can't get the resulting bitmap to look like the image on the right. It ends up looking like the image in the middle.

spriteBMD.draw(mySprite,null,mySprite.transform.colorTransform,"layer");

Does anyone know what I'm doing wrong?

BladePoint
  • 632
  • 5
  • 16

1 Answers1

1

I have some thoughts about the root cause, but anyway here how it works:

import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.display.Bitmap;
import flash.geom.ColorTransform;

var bmd:BitmapData = new BitmapData(mc.width, mc.height);
var bitmap:Bitmap = new Bitmap(bmd);

var sourceTransform:ColorTransform = mc.transform.colorTransform;
var bmdTransfrom:ColorTransform;

if(mc.blendMode == BlendMode.NORMAL)
{
    bmdTransfrom = sourceTransform;
}else
{
    bitmap.transform.colorTransform = sourceTransform;
}

bmd.draw(mc, null, bmdTransfrom, mc.blendMode);

addChild(bitmap);
Oleg Knaus
  • 300
  • 2
  • 7