@vamapaull:
Masks work analog to "pivotX/Y" and "clipRect" when it comes to coordinate systems, meaning: they are handled in the object's *local* coordinate system.
Think of it as if you'd add a child. Let's say for a moment that you could add the shape as a child of the image:
image.scaleX = image.scaleY = 0.5;
shape.width = image.width;
shape.height = image.height;
image.addChild(shape);
If image and shape had the same size originally, the shape will appear with a scale of 0.25 on the stage: both objects will have a scale of 0.5, and since they are nested, the total scale is a product of 0.5 * 0.5.
It's just the same with the mask, or with pivotX/Y, or with the clipRect.
If you want the mask to have the same size as a scaled object, you could do it like this:
image.scaleX = image.scaleY = 0.5;
shape.width = image.getBounds(image).width;
shape.height = image.getBounds(image).height;
image.mask = shape;
"getBounds(image)" will give you the bounds if the image in its own (local) coordinate system.
Although, since we're talking about an image, the following would work, as well:
shape.width = image.texture.width;
shape.height = image.texture.height;
So much for scaling; when we're talking about an object that is also moved/rotated/skewed, and you want the mask to be unaffected by this, I recommend to add the mask *not* to the object itself, but to a parent sprite. Again, if you wanted to use an overlay instead of a mask, that's what you would do, as well.
What do you think? Has it become clearer?
@all: To me, it feels as if that would be the appropriate way to do it in Starling; IMHO the behavior should be analog to pivotX/Y and clipRect, for example. But what do you think about this? I know it's different in classic Flash.