-- online Search!

Masking Dynamic Text and Device Fonts

by kirupa   | filed under Flash and ActionScript

Archive

This is an archived tutorial about Flash. It's kept for history and may reference outdated tech.

TL;DR

To mask dynamic text or device fonts, you can't rely on a timeline mask. Put the dynamic text field inside a movie clip, embed its fonts, draw the mask as another movie clip, and then call main_mc.setMask(mask_mc) from an actions layer to apply the mask with ActionScript.

  • The text area is set to Dynamic Text and Multiline before being converted into the main_mc movie clip.
  • Use the Character button to embed Uppercase, Lowercase, and Numerals if your data may contain numbers.
  • setMask takes the instance name of the clip to be masked and the instance name of the clip acting as the mask.
  • The same method works for device fonts, and the ActionScript dictionary is a good guide when you use new functions.

Why can't I mask dynamic text or device fonts yell's the inspiring flash developer!
It makes no sense! I can mask static text, why not dynamic text or device fonts?
Well Macromedia has a somewhat of an explanation here, but I'm going to try and explain this the best I can.

Basically you can only mask device fonts by using an actual movie clip as a mask.
You must also embed your dynamic text into a movie as well. You might not be used to this method as it's so convenient to use the timeline mask and most of the work you probably did in the past never required masking dynamic data loaded into a text field or text area. It's becoming so easy to generate external data in flash.

Here is an example of what we will create. A simple dynamic textarea with some text inside it with a mask applied to it:
 

[ an example of what you will create ]

Here is How
The following steps will explain what this tutorial will be trying to explain.

  1. Create a new flash document.

  2. Create a new layer and call it textarea.

  3. Draw a text area where you're dynamic text will be stored with your text tool.

Screengrab textbox

[grab your text tool, click on the stage and draw your textarea]

 
  1. When your finished drawing the text area, open your properties panel
    and select "Dynamic Text" and "Multiline".

    Screengrab property Panel
     
  2. Ok now we are going to convert the dynamic textarea into a movieclip . So hit F8 on your keyboard and call the movieclip main_mc.

    Also, you should embed your fonts. Click the Character button. The Character Options dialog box will appear. Check the option for Specify Ranges and select Uppercase, Lowercase, and Numerals if your data may contain numbers:

make sure to embed your fonts

[ make sure to embed your fonts ]
 

  1. Give your movieclip and instance name of main_mc as well.

    Screengrab mc instancename

     

  2. Create an additional layer in your timeline and call it mask. Draw a box covering the main_mc movieclip with the proper dimensions.
     
  3. Again we are going to convert the box to a movieclip. So hit F8 and call our movieclip mask_mc. Also be sure to give your new movieclip an instance name of mask_mc.
     
  4. Now we just have to add some actionscript to make it all work. Create a new layer and call it actions. Click inside the 1st frame of your timeline and open your actions pallet. Type the following script into your actions panel:
     
main_mc.setMask(mask_mc);

Details about setMask:


Availability : Flash Player 6

Usage :main_mc.setMask(mask_mc)

Parameters:
main_mc The instance name of a movie clip to be masked.
mask_mc The instance name of a movie clip to be a mask.

 
Robot metal icon Note
You should always use the actionscript dictionary as guide when using new functions. This method will also work for device fonts as well. Also search the forums on this topic, there are million's of threads regarding this. If you have questions about using text in flash check out this tutorial by Kirupa.

The following zip file contains the Flash source file used in this tutorial.

Well I hope this helps and clears up whatever questions you had about masking dynamic text and device fonts. If you have any questions be sure to visit the forums.

Until next time:

External resource (archived resource unavailable) Digitalosophy

 

Before you go, here are a few things you can do:

  1. Ask a question

    Stuck on something, or curious about a detail we skipped? Ask on the forums, and we’ll help you out.

Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence slop, ads, and algorithm-driven doodads. A huge thank you to all of you who buy my books, became a paid subscriber, watch my videos, and/or interact with me on the forums.

Your support keeps this site going! 😇

Kirupa's signature!

The KIRUPA Newsletter

Thought provoking content that lives at the intersection of design 🎨, development 🤖, and business 💰 - delivered weekly to over a bazillion subscribers!

SUBSCRIBE NOW

Creating engaging and entertaining content for designers and developers since 1998.

Follow:

:: Copyright © KIRUPA 2026 //--