I’d like to restrict users to entering only digits, a comma or period. What I have below works for the digits, but the trace returns fraction characters for the comma and periods.
Suggestions? Documentation for unicode?? Help!!!
(code requires textinput component in library)
import fl.controls.TextInput;
var allowedText:String = ",.1234567890" ;//"0-9;.,";
var inputText:TextInput= new TextInput();
inputText.move(100,200);
inputText.restrict= allowedText;
addChild(inputText);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler, true);
function keyHandler(event:KeyboardEvent):void {
trace("key="+String.fromCharCode(event.keyCode))
if (allowedText.indexOf(String.fromCharCode(event.keyCode)) > -1 ){
trace(("keyOK"));
} else {
trace("disallowed key");
}
}