Tag Archives: As2

Blocking Backgrounds in Flash

Note: This article was written in 2006 and applies to Flash ActionScript 2.

A very common problem in Flash (AS2) is as follows:

Your stage is covered in buttons and interactive movie clips and you want to put something on top of your entire stage and disable all the elements in the background all at once.

For example, you might be making an app with lots of text input fields and buttons. Let’s say you wanted to pop up a warning message on top of the screen to warn the user about something. Doing so, you want all the buttons in the background to be disabled.

Here’s a simple method to accomplish that task…

  1. Make a completely transparent rectangle the same size as your stage on the layer above everything that you want to block.
  2. Convert this rectangle to a Movie Clip.
  3. Give this Movie Clip instance a name of “blocker”.
  4. In the frame that the movie clip appears, write the following ActionScript:

Actionscript:

this["blocker"].onRelease = function() { };
this["blocker"].enabled = false;

Doing this creates a movie clip which has an “onRelease” action assigned to it. Even though we’ve assigned no code to the onRelease function, Flash still sets up the Movie Clip to be clickable. The second line of code disables the clip so that it isn’t clickable. By doing so, you successfully block everything beneath the clip. Voila!

Flash Components Missing Fonts

So here’s a nice bug that took me about a month to figure out:

  1. Make a component (SWC file) in Flash 8 that uses a Dynamic text field. Set the font to Arial and make sure that you embed the characters that you need. I embedded [a-zA-Z0-9].
  2. Export your SWC file.
  3. Drag your component from the Components panel into a new flash file.
  4. If your flash file does not use any text fields that contain the font Arial, then you’ll be good to go. However, try putting a static text field on your stage with the word “HELLO”. If your Flash acts the same way that mine does, it will drop all of the embedded characters from your component except for the characters that appear on the stage (i.e. H, E, L and O).
  5. The only solutions that I have found are:
    1. Make a separate dynamic text field off the stage which embeds all of the characters that your Component does. This solution is not recommended though, because if your component ever changes its font, you may run into the same problem all over again.
    2. Never use static text on the same stage that you are putting a component. This seems a bit drastic, but if you make a point of only using dynamic text fields with reasonable font sets embedded, then you will run into this problem less.

I emailed Adobe about this problem, but they wouldn’t support me because they don’t deal with custom components. Hopefully it’s addressed and fixed in future versions.