I'm trying to make a mask with bitmaps, i.e. has such a shape below. Here my image mask:
All, in above image, is not white is transparent. So applying a mask she cuts a rectangle instead of this form. Is there any way to implement it? Primitives will hardly make such a mask.
Here my source:
package
{
import flash.display.Bitmap;
import flash.display.Sprite;
[SWF(width="960", height="640", frameRate="60", backgroundColor="0x4a4137")]
public class Main extends Sprite
{
[Embed(source="jack.jpg")]
private var PhotoImg:Class;
[Embed(source="faceArea.png")]
private var FaceAreaImg:Class;
private var _imageBox:Sprite;
public function Main()
{
createMask();
}
private function createMask():void
{
var img:Bitmap = new PhotoImg();
_imageBox = new Sprite();
_imageBox.x = 0;
_imageBox.y = 0;
_imageBox.addChild(img);
addChild(_imageBox);
var faceArea:Bitmap = new FaceAreaImg();
faceArea.x = 50;
faceArea.y = 50;
addChild(faceArea);
_imageBox.mask = faceArea;
}
}
}
Hi skyboy
If you want to make masking with transparent bitmaps, you have to make the cacheAsBitmap property of the two DisplayObjects to true.
try:
_imageBox.cacheAsBitmap = true;
faceArea.cacheAsBitmap = true;