Create a realistic particle based firework display using Flash. This technique was once us..
A collection of futurstic textures used in the Future city project...
A list of great sites to submit your tutorials and articles that actually bring traffic to..
A look at the things I've done over the past few months that have dramatically increased m..
Heres a collection of amazing photos from street artist Peter Gibson, this work is amazing..
Learn how to use Photoshop textures and filters to create this ph..
If your learning Flash this is a must know, as it will help you t..
This video shows off the upcoming Flash "Next" 10 from the Adobe ..
While searching for a bad word filter script for one of my flash projects I couldn't really find a simple answer, there were loads of big looping scripts and over the top ways of doing this, but hopefully you will find this the simplest and most effective.
First convert your input field to lowercase characters, this will save you confusion and also save you from writing out multiple bad words to filter i.e Badword, badword, BadWord etc
text_field = text_field.toLowerCase();
Create a new variable name for this example this will be called "field_check". We now need to set "field_check" to the same value as our original "text_field" but also remove any bad words we don't want from the string and replace them with "" (or nothing).
field_check = text_field.replace("badword1", "").replace("badword2", "").replace("badword3", "");
We now use an If Statement to compare the two variables to see if any changes have taken place, remember if the above script found any bad words listed it would of replaced them with "" (or nothing) so the new variable will now be different from the "text_field".
if (field_check != _level0.text_field) {
error_message = "Word not permitted!";
} else {
play();
}
};
Heres the final bit of code within a button event handler. You may also notice that ive made it write a message in another text field telling the user that the words entered were not permitted (but only if the two variables don't match after the replacing).
on (release) {
text_field = text_field.toLowerCase();
field_check = text_field.replace("badword1", "").replace("badword2", "").replace("badword3", "");
if (field_check != text_field) {
error_message = "Word not permitted!";
} else {
play();
}
};
The good thing about this technique is you don't need to enter a massive list of words because once it picks up the word "flash" for example the word "flashing" and "flasher" also become part of the bad word and the error is still shown.
Send to a friend