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!

3 Thoughts on “Blocking Backgrounds in Flash

  1. Pablo S. on May 8, 2006 at 4:05 am said:

    THANK YOU SO MUCH FOR THIS!!

  2. No problem. Glad I could help!

  3. I wanted to add a comment here to let people know that this article really only refers to versions of flash earlier than Flash 9 and ActionScript 3.0. If you’re experiencing problems not being able to click through the top movie clips, please see my article on Un-blocking backgrounds in Flash.

Leave a Reply

Post Navigation