AS2 → AS3: Setting Masks Dynamically

Download Example Files

The more migrating I do to AS3 the more little nuances (at least nuances when I am migrating) I find. A lot of small little methods have been switched or moved into new classes and it's always a bit of a drag to find them. Such is the case with the setMask() command.

Although setMask() was a very simple command in AS2, it is not even easier in AS3. The following is really a basic overview and there really isn't much more to it.

Let's look at the AS2 code for setting a mask dynamically with setMask():

Actionscript:
  1. box_mc.setMask(circle_mc);

As simple as that is, it is even simpler in AS3:

Actionscript:
  1. box_mc.mask = circle_mc;

This not only looks cleaner but makes a lot more sense. After fumbling around with trying to find where setMask() went, this was a great solution.

If you found this post useful, please consider leaving a comment, subscribing to the feed, or making a small donation.

2 Comments

cool one!

Great! Thanks!

Leave a comment

(required)

(required)