PDA

View Full Version : Scanning text


street_spirit
10-23-2007, 09:44 AM
Hi, I have a question relating to actionscript, not sure if I ill be using actionscript 2.0 or 3.0, they have flash cs 3 on the Macs at Uni but you can program in either as I recall.

Anyway basically what I want to do is have an application with the ability to scan through text someone has say copy and pasted into a text box and look for key words and then say if found 'thing' then print 'i found thing' or some other action. Even cooler would be the ability to read for a html document say, but thats really in the future maybe. Anyway know any references that would help with this? Or tutorials along these lines?

Thanks, David.

senocular
10-23-2007, 02:44 PM
all you need to do is use the indexOf() method on the variable containing the text. If its in there, you'll get a number 0 or greater. If not, it will be -1.

var text = "what a wonderful thing"
var result = text.indexOf("thing");
trace(result); // 17

street_spirit
10-24-2007, 08:57 AM
Thanks, excuse my poor programming knowledge but if you wanted to had it so it was a text box that the user had copy and pasted the text you wanted to scan into it would just be:

Var [instance name] ?