0

How to make some Shape or Bitmap to became unmovable mask, which cut all graphics above mask. (they laying in different containers with different coordinate spaces)

Some explanation: I have some vector Shape in one class, some Bitmap images in another. I want to make shape acting like "mask", cutting images which above Shape.

I has two ideas, but they does not work:

1)I tryed BlendMode, but they works another way - if i want to erase some image, this image must be parent of masking image, which is not acceptable in my case: images could move, but mask should be unmovable. Also i can't move mask to a child container of image, because they in different coordinate spaces. I made explanation diagram: https://i.stack.imgur.com/Spbx4.png

2)Use .mask property with masking layer. But mask and bitmap in different coordinate spaces, so this don't work too.

kolombet
  • 87
  • 1
  • 1
  • 7
  • Not entirely sure what it is you want to do, but one thing that could work is to make a copy of the shape, put in in the same "coordinate space" as the bitmap and use that shape as a mask, instead of the original one. – Lars Blåsjö Mar 19 '13 at 17:22
  • You got me right, move copy of shape to other coordinate space is another solution. But it's not compatible with BlendMode, which require mask layer to be child of image layer (or otherwise, image layer to be child of mask layer) which unacceptable if mask layer must be unmovable relative stage, but image container moves. – kolombet Mar 22 '13 at 10:59

1 Answers1

0

Mask is solution! I made black mask, in which i draw my shape with BlendMode.Erase property. So i get in this mask transparent shape-formed hole. Then i set it to the .mask property of my image and set to image and mask .cacheAsBitmap = true. Mask and image must be added to stage (and mask .visibility = false).

This way mask start working and zones with transparency "cut" my image.

kolombet
  • 87
  • 1
  • 1
  • 7