Hello there i had another problem but this one is weird and does not work as expected
I had a text input component i add a function to it, when a user type a text it start to search in an array, the problem is when i type the first letter the output is blank and when i type the second letter the function reads only the first letter
here is the code
workArray is the object that stores workTitle and workCost
work.addEventListener(TextEvent.TEXT_INPUT, inputInWorkBox);
function inputInWorkBox(TextEvent) {
trace("Function worked: "+work.text.toLowerCase());
todayWorkList.removeAll();
var typedWork = work.text.toLowerCase();
var fullWork:String = "";
for (i = 0; i <= workNumber; i++) {
fullWork = (workArray[i].workTitle).toLowerCase();
if (fullWork.search(typedWork) != -1) {
todayWorkList.visible = true;
todayWorkList.addItem({
label: (workArray[i].workTitle),
data: workArray[i]
});
}
}
}
here is the output
Function worked: // i typed a
Function worked: a // i typed ab
Function worked: ab // i typed abc
Function worked: abc // i typed abcd
BTW: i don't want to use CHANGE Event because the data in the text input changed by other functions to display some data i want it to call the function only when a user type inside that specific text input
thanx in advance
Here's the quote from the CHANGE event:
That means that TextEvent.TEXT_INPUT is dispatched before the text in the TextField is actually changed, which totally agrees with the results you get (although it is not explicitly mentioned in the TEXT_INPUT chapter itself) AND works EXACTLY as expected.
Then, the documentation states that TEXT_INPUT event has a text property which contains the new content of the TextField.
Thus, your code should be something like