textInput Eventpackage{ import flash.text.TextField; import flash.display.Sprite; import flash.events.TextEvent; public class Main extends Sprite { private var inputText:TextField; private var regex:RegExp; private var dict:Array; public function Main() { dict = new Array("flash", "java", "C#", "python", "ruby", "C++"); inputText = new TextField(); inputText.type = "input"; inputText.addEventListener(TextEvent.TEXT_INPUT, predictText); inputText.border = true; addChild(inputText); } private function predictText(textEvent:TextEvent):void { this.regex = new RegExp(textEvent.text, "i"); for each(var term:String in dict) { if(regex.test(term)) { inputText.text = term.substring(textEvent.text.length); } } } }}
Name (required)
email (will not be published) (required)
Website