I was testing something here and found that the AS command Split() is not available in 3dfa This is a VERY usefull command as it lets you send an array from the server as a comma delimited string and turn it back into an array in flash.
So being me I just wrote my own function to do the same thing.
Example call
code:
string1="one,two,three,four,five,six,seven,hi there"
myarray=root.split(string1,",")
trace("array length="+myarray.length)
for (x=0;x<myarray.length;x++){
trace(myarray[x])
}
where string1 is the string with the data in it. You can use any delimiter but comma is commonly used.
Heres the function
code:
function split(BL_string,delimiter){
BL_array=new Array()
/* Function to replace missing split functionality
call it myArray=root.split(string,delimiter)
*/
//Get first element in array
first=BL_string.indexOf(delimiter,0);
end=BL_string.indexOf(delimiter,first+1);
BL_array[0]=BL_string.substr(0,first);
//Now get the rest of the elements
start=first
idx=1
while(start<>-1){
end=BL_string.indexOf(delimiter,start+1);
if (end==-1){
BL_array[idx]=BL_string.slice(start+1,BL_string.length);
}else{
BL_array[idx]=BL_string.substr(start+1,(end-start-1));
}
idx++
start=BL_string.indexOf(delimiter,start+1);
}
return BL_array
}//end if split function