I have a function that searches a string for words that are not in a "whitelist", and replaces them with ###. It searches the original string and places all the words not in the whitelist in an array (
badWords). I've just added the code that censors out the string. Here it is.
ActionScript Code:
if(messageOK == false)
{
var censoredMessage:String;
for(var m:int = 0; m < badWords.length; m++)
{
censoredMessage = chatField.text;
censoredMessage = censoredMessage.replace(badWords[m], "###");
if(m == badWords.length - 1)
{
generateBubble(charName, censoredMessage, 0, 200);
badWords = [];
}
}
}
The new string (censoredMessage) only censors the last "bad word" in the array.
Any ideas?
Thanks in advance,
Jacob
/////////////////////////////////
[EDIT]
Figured it out! I accidentally put censoredMessage = chatField.text; in the loop.