Here's one for you POM

Since you seem to be the go to person,:slight_smile: Here is what I want to do:

I have a list view that is set up so I can enter in Org #'s like 5091, 5067, 5878 and so on. I want the users to be able to put in as many as they want. I need to extract these orgs from the list view and place them in a variable that I can display later in the movie. I can extract them but I get 509150675878 all group together. I would like to be able to insert a comma after every 4th character. I think you need to create a function to format the string. I was not sure on how to do this. Or is there some way I can do it before the extract. Thanks in advance for your help

Here you go:

String.prototype.sliceIt=function(){
	var length=this.length;
	var myArray=new Array();
	var i;
	for (i=0;i < length/4;i++){
		myArray*=this.slice(4*i,4*i+4);
	}
	return myArray;
}

// How to use it:
myString="12345678909876543212";
trace (myString.sliceIt());
// returns 1234,5678,9098,7654,3212

Basically, it is done with the slice method. You can check it in the AS dictionnary.

pom :asian:

Thank you so much. It work like a freakin charm… Is there anything you do not know? lol Thanks for always being so helpful

Your Friend
MXN

:stuck_out_tongue:

pom :asian:

cool code, POM. One question… doesn’t the array return the values separated by commas anyway? I’m not fooling or anything, I really want to know. I think it’s just been a long day and I’m just staring at the screen, not knowing what to write.

:slight_smile:

Sorry to get back to you so late.

Yes it does, but this wasn’t the point. He wanted to have groups of 4 digits… But anyway, I don’t think the comas are actually “there”: Flash puts them there so that you can see the output.

If you really want to put comas, I think it’s the join method, but I’m not sure.

pom :asian: