var tempString:String="[email protected];[email protected]";
var tempArray:Array=tempString.split(";");
//tempAc is a predefined and presumably prepopulated arraycollection
for each(var email:String in tempArray) {
tempAc.addItem(email);
}
EDIT Now that I see Shane's answer I must add the following:
This code will append the array to the arraycollection. If you just want to create a new arraycollection, all you need to do is:
var tempAc:ArrayCollection=new ArrayCollection(tempArray);
or in 1 line,
var tempAc:ArrayCollection=new ArrayCollection(tempString.split(";"));
UPDATE - to answer questions in the comments:
tempAc.getItemAt(i) will give you the email id at the i th position
tempAc.getItemIndex("[email protected]") will give you the index at which [email protected] exists in the arraycollection (or -1 if not contained)
tempAc.contains("[email protected]") will return true or false depending on if the string is contained or not in the arraycollection
So, to check for duplicate ids, all you got to do is:
var newEmailId:String="[email protected]";
if(!tempAc.contains(newEmailId)) {
tempAc.addItem(newEmailId);
}