View Full Version : Text detection in a input.
mole_incarnate
06-02-2005, 07:28 AM
Ok Hi and all that, difficult one coming up im thinking.
Ive done this before a long time ago in java, but I have no idea how to do this in flash, I have a input text box, and a whole heap of radio buttons. The radio button needs to change to 'selected' when certain things are put into the input box, eg it changes to address when theres '*number* *space* *letter*', or to date when its '*numbers*/*numbers*/*numbers*' if you get what I mean.
Any help on this would be greatly appreciated, as I have no idea where to start with this one, so we can really impress our clients. (This is for a online based training application, that is as close a replication as possible to their product).
Edit: Oh I forgot that I was going to be using Actionscript 1.0 even tho im using flash 2004 :/ if a mod could move this at some stage that would be great. Edit2: Scratch that, I have to use actionscript 2.0 anyways, so just ignore that first edit :P
Joepieman
06-02-2005, 09:34 AM
What you need to do is define a function which handles TextField.onChanged events. This way you can handle all changes, and do what you need to do with that. ie: perform some String functions on the TextField.text within the event handler to get what you want.
this is the url which describes TextField.onChanged (but you should know this, you have this neat lil actionscript dictionary on your own computer):
http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004&file=00001796.html
one method is to split the string by "/" and see if there are multiple items:
if (myTextBox.text.split("/").length > 1) {
//date
} else {
//address
}
hope this helps :)
mole_incarnate
06-03-2005, 01:21 AM
Thanks for pointing me in the right direction, I should be able to figure out the rest on my own, but any further help would be appreciated.
Edit: Ok ive got it detecting the changes which is good. But I dont get how I can use split to find out if it contains certain orders of letters/numbers/symbols. Is there some way I can just go something like
if (inputText.text == 'number', 'number', '/') {
dateRadioButton.selected = true;
}
Either that or im just not getting split :/ I think ill need a example code or something to get me started, I looked at the reference for it and it didnt really help at all.
this.createTextField("myInputText_txt", 99, 10, 10, 300, 20);
this.createTextField("T", 199, 10, 30, 300, 20);
myInputText_txt.border = true;
myInputText_txt.type = "input";
myInputText_txt.onChanged = function(textfield_txt:TextField) {
//this isn't to nice normaly it shoud just by set if it's not the one or the other
//but it's to fast that a human woud realyze something
_root.T.text = "UNRECOGNICED";
if (textfield_txt.text.indexOf("/")+1) {
Temp = textfield_txt.text.split("/");
if (Temp[0] == Number(Temp[0]) && Temp[1] == Number(Temp[1]) && Temp[2] == Number(Temp[2]) && Temp[3] == undefined) {
_root.T.text = ("NUMBER FORMAT");
}
}
if (textfield_txt.text.indexOf(" ")+1) {
Temp = textfield_txt.text.split(" ");
if (Temp[0] == Number(Temp[0]) && Temp[1] && Temp[2] == undefined) {
_root.T.text = ("DATE FORMAT");
}
}
};
mole_incarnate
06-03-2005, 01:46 AM
Heh you read my mind, that will help hugely with what im doing. Thanks a lot :)
Edit: Ok heres problem 2.
I have a very large mySQL database, what im supposed to do is output data from this database into a table, in this case im using the STable component, which uses addRow(array);. Now getting it in there isnt too much of a problem, but what I need is something a little more advanced, theres a search function, so that if you searched for say, Smi, it would come up with all the people with the lastname Smi and variants thereof, so it would also come up with Smith, Smitty, Smists or whatever. Theres also other search options, like date of birth etc, thats what all the other stuff I asked for help on was for. I really need some help on this one ^^ We're using PHP to query the database and get the data from it.
Actually never mind, I think I got that as well :/ Just cause im a silly poo.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.