Search in Flash
- Started
- Last post
- 11 Responses
- Sir_Askalot
does anyone know a simple way to detect if an input text in flash has a determined word? as in check if the user typed the word "fuck" then return a true variable... what a mess I don't know if I am explaining myself properly.
- mercy670
yeha i know what you are talking about.
email me and i will send you my code that i used to check in input.
- frankbb0
check you mail
- Sir_Askalot0
cheers guys, this is very helpful! :)
- to0
i wanna check my mail too.
please frankbb. send it to me.
- lostnation0
Something like this should work:
textfield.prototype.hasText=func...
if(this.text==txt){
return true;
}else{
return false;
}
}usage:
if(yourTextField.hasText('textTo...
//do this;
}else{
//do this
}
- frankbb0
the above one is better for checking for words against words..
very simple...mine was to check against stuff while your typing(or/and on submit) and giving you an answer whilst you are doing it...
- to0
again frankbb...can you send it me?
cheers
- Sir_Askalot0
mmm this work fine, but i think what I need is a way that after the user has typed in a paragraph Flash knows if certain keywords are in the paragraph... sounds so simple that must be really complicated to do! argh!!
- frankbb0
the one I sent you Sir_Askalot should do exactly that..
hold on.. i will do a new one for you..
- Sir_Askalot0
No worries Frankbb, I got it working now! so simple... I am a happy man, ready to enjoy a long weekend :) thanks to everyone!
- lostnation0
One last try for good measure. This works with mutliple keywords:
textfield.prototype.hasKeywords = function(kwords) {
delete this.results;
for (i=0; i<arguments.length; i++) {
if (this.text == arguments[i] || this.text.indexOf(arguments[i]) != '-1') {
if (this.results == undefined) {
this.results = new Array();
}
this.results.push(arguments[i]+' found at character '+this.findLoc(arguments[i]));
}
}
if (this.results != undefined) {
trace(this.results);
return this.results;
} else {
trace("no keywords found");
return false;
}
};
textfield.prototype.findLoc = function(txt) {
return this.text.indexOf(txt);
};
yourTextField.hasKeywords('keywo... 'keyword2');ooh...happy weekend!