Masking Test & Input Fields in Flash

A common problem in Flash involving text and masking. Check it out!

Normally, mask setting in Flash IDE don't work for dynamic TextField and TextInput components. With default settings, you'll not be able to see the text through the mask. People using masked layers from Flash IDE often fall into this problem. One stupid solution to this problem is not using mask at all. However, if you want to implement something like custom scrolling, sliding etc. then most of the time you'll need to use mask.

The solution to this problem is rather simple if you use ActionScript.

Since this scenario is true only for layered mask, where you create a new layer from Flash IDE and then right click on that layer to make it as a mask for other one or more layers.  DisplayObject mask doesn't have the same problem. So, instead of selecting layered mask from your flash IDE, use mask property of DisplayObject class from ActionScript (in ActionScript 3).

YourDisplayObject.mask = maskObject;

For ActionScript 2, use the setMask method:

YourDisplayObject.setMask(maskObject);

Now you'll be able to see Dynamic TextField and TextInput from a masked object or MovieClip properly. I'll be adding an example of this problem and the solution shortly, so stay tuned.

PS: Don't ask me how you will solve the problem if you don't want to use ActionScript. Since the problem occurs only for dynamic fields (Fields created and/or modified by ActionScript). So if you are not using ActionScript in your Flash movie, then you will not have the same problem (Exception: Device Font don't work inside layered mask, even if it is generated without ActionScript and used as static text)


Update: Example demonstration is added. See this Example ActionScript Tutorial for better understanding of the problem and and the solution (.fla and .as source code available).

4 thoughts on “Masking Test & Input Fields in Flash”

  1. Fayaz.......

    I dont have words to say.... except a grt THANKS.

    You saved a lot of time... and ACTION SCRIPT rocks...

Leave a Reply to Fayaz Ahmed Cancel reply

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