all groups > flash actionscript > may 2004 >
You're in the

flash actionscript

group:

fastest way to turn a string into array of chars?


fastest way to turn a string into array of chars? sneakyimp
5/17/2004 10:10:58 PM
flash actionscript:
hi:

i want to take a string and turn it into an array of characters so that i can
pass it by reference to a function. i've seen some really quick ways to cast
variables in other languages, but this is what i currently have in actionscript:

strCharArray = new Array();
intTmpLength = strTmp.length
for (i=0; i < intTmpLength; i++) {
strCharArray = strTmp.charAt(i);
}

is there a faster way or is this method the optimum way?
Re: fastest way to turn a string into array of chars? tralfaz
5/17/2004 10:34:40 PM
[quoted text, click to view]

whoa.. I didn't know that splitting with a null would devide up the entire
sring like that. Very good! I can use that.
thanks!
tralfaz

Re: fastest way to turn a string into array of chars? mandingo
5/17/2004 11:02:56 PM
You want to put a string into an array?

someText = "this is some display text";
someArray = someText.split("");

if you trace :

trace(someArray); // the entire array
trace(someArray[8]); // the 8th element of the new array

hope that helps
cheers,

Re: fastest way to turn a string into array of chars? sneakyimp
5/17/2004 11:18:56 PM
THAT's what i'm talking about! thanks.
Re: fastest way to turn a string into array of chars? mandingo
5/18/2004 5:45:41 AM
thats only fair tralfaz, there have been some of your little bits and pieces I
have learnt from too. :)

I think I first did it by mistake... meant to do it as a split(" ") on spaces
only

cheers,
Re: fastest way to turn a string into array of chars? tralfaz
5/18/2004 2:33:33 PM
[quoted text, click to view]

What a way to have to find out something useful.. by accident, because the
docs suck so bad. Such a small investment for MM too. They could easily
document the ActionScript with a very minimal effort. One employee could
probably do the whole thing with a couple of weeks work. If they did I
wouldn't have to take so many notes from forum posts!

Have a gud 1
tralfaz

Re: fastest way to turn a string into array of chars? sneakyimp
5/18/2004 5:06:15 PM
i did actually read the documentation on SPLIT, hoping it would do that and the docs said nothing about it. they really need to do something about the documentation.

AddThis Social Bookmark Button