Creating an autocomplete textfield using xml....having a strange issue
so looking create autocomplete textfield (a lã google) creates it's suggestions based on xml nodes. far have code in place thats uses txt file (which fine , dandy have xml complete , use elsewhere).
when swap .txt file xml file no errors don't suggestions.... still learning here help, thoughts, ideas helpfull (especially when explained me)
public function main():void { urlloader.load(new urlrequest("sports.txt")); urlloader.addeventlistener(event.complete, loadcomplete); inputfield.addeventlistener(keyboardevent.key_up, suggest); format.font = "helvetica"; format.size = 12; format.bold = true; } private function loadcomplete(e:event):void { suggestions = e.target.data.split(","); // here i've swapped 9"," ("\n") } private function suggest(e:keyboardevent):void { suggested = []; (var i:int = 0; < textfields.length; i++) { removechild(textfields[i]); } textfields = []; (var j:int = 0; j < suggestions.length; j++) { if (suggestions[j].indexof(inputfield.text.tolowercase()) == 0) { var term:textfield = new textfield(); //here define textformat if (inputfield.length == 0) { suggested = []; (var k:int = 0; k < textfields.length; k++) { removechild(textfields[k]); } textfields = []; } if(e.keycode == keyboard.down && currentselection < textfields.length-1) { currentselection++; textfields[currentselection].textcolor = 0xffcc00; } if(e.keycode == keyboard.up && currentselection > 0) { currentselection--; textfields[currentselection].textcolor = 0xffcc00; } if(e.keycode == keyboard.enter) { inputfield.text = textfields[currentselection].text; suggested = []; (var l:int = 0; l < textfields.length; l++) { removechild(textfields[l]); } textfields = []; currentselection = 0; } } // goes on repeat these keyboard functions mouse equivalents
suggestions array populated data in sports.txt, not xml file.
More discussions in ActionScript 3
adobe
Comments
Post a Comment