Masks

The other day I was trying to animate a mask on a Sprite. It was working only very jerkily or not all. After a lot of trial and error I decided to re-read the docs on masking a Sprite. It turns out you need to add the mask to the the Stage before you can animate it. Quite strange when you are used to just setting the mask in ActionScript 2.

ActionScript

  1. var mc:Sprite = new Sprite();
  2. // ... fill mc with something
  3. var myMask:Sprite = new Sprite();
  4. // ... draw the mask
  5. addChild(mc);
  6. addChild(mask);
  7. mc.mask = myMask;
  8. // .. now animate away!!! :)

Leave a Reply

Your email address will not be published. Required fields are marked *