|
-
the cheesy child
Find certain words in a text field
Hi everybody!
I have had alot of ideas for a chatroom but there's a few problems... i want to make sure certain words can't be said!
I don't want swearing, but I would like to just change the swearing to other things so that the message will still be sent and not just be annoying.
eg: F*** can be fudge
S*** can be Shoot
etc.
please tell me, and i don't want to have to be using PHP!!!
-
FK'n_dog
does this method work for you ?
on stage -
input textfield - instance name - inp
button - instance name - btn
PHP Code:
exclWords = ["f*ck","sh*t","a*s"]; // fill in the blanks
inclWords = ["fudge","shoot","uss"];
btn.onRelease = function(){
findWords(inp.text);
};
function findWords(str){
temp = str.split(" ");
for(var v=0;v!=exclWords.length;v++){
for(var w=0;w!=temp.length;w++){
if(temp[w] == exclWords[v]){
str = str.split(temp[w]).join(inclWords[v]);
}
}
}
sendTxt(str);
};
function sendTxt(newStr){
trace(newStr);
};
-
the cheesy child
thank you very much a_modified_dog
unless you are doing something, would you mind explaining the script?
i am new to arrays.
-
FK'n_dog
excluded words in array - exclWords
replacement words in array - inclWords
on button press -
send inp.text to function - findWords(inp.text);
split inp.text to array - temp
cycle thro' temp comparing against exclWords
if an exclWord is found, replace it with inclWord
when complete, send the new string to function sendTxt and display in output window.
-
the cheesy child
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|