Copy link to clipboard
Copied
So i have a list of numbers. The user is able to then add numbers to that list. I have a button which allows the user to remove any number of their choice by typing that number in a textbox. For some reason the numbers that the user add to the list will not dissapear when chosen whereas the original numbers go away no problem.
The name of the array itself is mesEntiers and the name of the texbox is : IntegersIn_txt
Here is the code :
function supprimer(event:MouseEvent):void
{
var indiceChiffre:int;
indiceChiffre =(mesEntiers.indexOf(IntegersIn_txt.text));
// La méthode indexOf renvoie l'indice d'un élément ou -1 si non trouvé.
trace("testBtn")
if (indiceChiffre != -1)
{
for (var i=indiceChiffre; i <mesEntiers.length; i++)
{
mesEntiers = mesEntiers[i+1];
trace("test")
}
mesEntiers.pop();
}
} // Fin fonction supprimer.
Two things I can think of (I ran a small test)...
1) Make sure your textfield is a single line, not multiline... multilines end up with extra stuff in them that you can't see.
2) Convert the text into a number unless the array is holding strings... indiceChiffre =(mesEntiers.indexOf(Number(IntegersIn_txt.text)));
Copy link to clipboard
Copied
Two things I can think of (I ran a small test)...
1) Make sure your textfield is a single line, not multiline... multilines end up with extra stuff in them that you can't see.
2) Convert the text into a number unless the array is holding strings... indiceChiffre =(mesEntiers.indexOf(Number(IntegersIn_txt.text)));
Copy link to clipboard
Copied
Awesome! I made the change #2 and converted them into Numbers and it works like a charm now. Thanks a lot!
Copy link to clipboard
Copied
You're welcome
Find more inspiration, events, and resources on the new Adobe Community
Explore Now