Written by: Warrior
Difficulty Level: Intermediate
Requirements: Flash 5 and above
Download FLA

Let me start by saying that if it weren't for PixelWit's help, this tutorial would not be here so every one give a BIGUP to PixelWit. I still have to write the tutorial for The Matrix effect. Ricod is not going to like me anymore because I left it for a long time (^_^)

As the title say's, we are going to ban certain words in this form so that it cannot be submitted if certain words exist. An obvious application for this is stopping the use of swear-words in community forums and other unmediated posting systems. Open Flash and make three layers like the picture below. One for ActionScript, one for the InputBox and one for the button.

Right click on the ActionScript Keyframe and paste this code inside it.

// We do not list legitimate swear-words below for professional reasons
// but you get the idea...
badWords = ["cat", "dogs", "bunnies", "cats"];

We have just created an array of words we do not want the user to submit. Now make a text field and turn it in to an input text. Make the line type multiline and give it the variable name “Box”. You can give it any name but for this tutorial we will use the name “Box”. Make another text field but keep it small because that will be the box that informs us if we have entered a swear word or not. Give the small box the name “Status” and make it a dynamic text. Here is the picture of the two text field's.

Now create button and place it in the Button layer (obviously) and put this code inside it.

on (release) {
        // If the Box has no text inside it, tell the user to enter a message
        if (Box eq "") {
                Status = "Enter Message";
        // This goes through every element in the array.
        //It basically says do whatever follows to every element in the array.
        for (i in badWords) {
                // This says if the current element in the badWords array is
                //found in the "box" string then there is a bad word present.
                if (Box.indexOf(badWords[i])>-1) {
                        Status = "No Swearing";
        Status = "Clean Message";

Now you're done. You can use any word you want by editing the array.

Feedback, comments or help e-mail to