Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-14-2012, 10:24 PM   #1
FusionFactor
Senior Member
 
FusionFactor's Avatar
 
Join Date: Jun 2011
Posts: 167
Exclamation String Not Being Replaced

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.

Last edited by FusionFactor; 06-14-2012 at 10:46 PM.
FusionFactor is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:23 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.