Need help with array

Hi…

Ok what I after is how to “+” 1 for duplicate elements in array …let’s say I just push the value in array like this…


someArr = [one,two,three,four];

so next time I want to push the same name elements eg; “one”…so how to make so that the code can check for any existing file name then it found the duplicate name it will plus “1” to make it different…so the final value in array will be like this…


someArr = [one,two,three,four,one1];

so next time the code will stil check for duplicate name…maybe I wil have the value in array liek this…


someArr = [one,two,three,four,one1,one2,two1,three1];

it is because later on i want to remove some value from this array…so far what I have is it not checking for duplicate…so when I’m delete soem value in array it will delete all the same name…eventhough I want to delete one elements only…here;s what I have so far



stop();
//define empty array
var myArray =  [];

//push value into array
addbtn.onPress = function(){
    myArray.push(input_txt.text);
    input_txt.text = "";
    output_txt.text = myArray;
}
//delete value in array

delbtn.onPress = function(){
    for(var i = 0;i<myArray.length;i++){
        if(input_txt2.text == myArray*){
            myArray = myArray.remove(myArray*);
            output_txt2.text = myArray;
            break;
        }
    }
}

Array.prototype.remove = function(obj) {
  var a = [];
  for (var i=0; i<this.length; i++) {
    if (this* != obj) {
      a.push(this*);
    }
  }
  return a;
}


u can try it here…

http://fifin04.propertyaccess.com.my/array/arrayquestion.html

the fla’s

http://fifin04.propertyaccess.com.my/array/arrayquestion.zip

I’m really need help with it…any help would be appreciate…

tq

thanks for the reply guys…Macaroni Ted and Stringy…

nice code there…it works like a charm now…

thanks again…:beer: