I have a function that calculates how many characters remaining the user can type, but I don't know why it only starts counting from the 2nd characters. Means at the end I will able to type an extra character from the maximum amount I set.
wInput.maxChars=30
wInput.addEventListener(KeyboardEvent.KEY_DOWN, calculate);
private function calculate(event:Event=null):void {
NameRC=wInput.maxChars-wInput.length;
remainingA.text=NameRC;
}
wInput function:
private function input():void {
//name input
wInputF.font=arial.fontName;
wInputF.color=0x818181;
wInputF.size=15;
wInputF.align=TextFormatAlign.JUSTIFY;
wInputF.leftMargin=5;
wInputF.rightMargin=10;
wInput.defaultTextFormat=wInputF;
wInput.border=true;
wInput.borderColor=0xE6E6E6;
wInput.selectable=true;
wInput.type=TextFieldType.INPUT;
wInput.maxChars=30;
wInput.width=wBox.width-wType.textWidth-70;
wInput.height=wInput.textHeight+5;
wInput.x=wBox.x+wType.width+10;
wInput.y=wType.y-5;
wBox.addChild(wInput);
//calculate remaining characters
remaining();
remainingC.x=wInput.x+wInput.width+20;
remainingC.y=wInput.y+12;
wInput.addEventListener(KeyboardEvent.KEY_DOWN, calculate);
}