Groups | Blog | Home
all groups > flash actionscript > october 2004 >

flash actionscript : string mayhem


robotstyle
10/12/2004 9:30:57 PM
Greetings,
I am trying to convert "letters" into a split string where I can call on
spacific points in the string.
_____________
letters = new String("Once upon a midnight dreary");
letter = letters.split("");
trace(letter[2]);
-----------------------
The above works fine, and returns "s", but when I put into a project I am
working on, it doesn't split the string! Instead, it puts all the text on
"letter[0]" !!! "letter[2]" is stated as "undefined" ! What am I doing
wrong?

You can download the fla here:
members.aol.com/robotstyle/string_draw.fla
_jrh_
10/12/2004 9:49:44 PM
You forgot the space in your split ;)

letters = new String("Once upon a midnight dreary");
letter = letters.split(" ");
trace(letter[2]);

robotstyle
10/12/2004 10:21:26 PM
Thanks JRH, but I guess I worded my problem bad. I want each section of the
string to be a single letter. That's not the problem. The script in my above
post works exactly as I want it to... ALONE. The problem is that when I put the
same scripts in ANOTHER project im working on, it messes up, and puts all the
text on "letter[0]" .
_jrh_
10/12/2004 10:53:09 PM
robotstyle
10/12/2004 11:39:17 PM
hmmmm, Well something is conflicting with it within this movie, because I tried
it in another similar past project, and it worked fine. Im going to try and
rewrite the movie simpler and on one frame. It's probably something sloppy on
my part, thoe I've been at it for 2 days now, and have gone through it several
times to find the problem, with no luck. It's wierd that it would work one way
in one file and differenty in another. I'll post the solution if I ever find
one. Thanks JRH for taking the time out to help. What's so frustrating is that
I know when I get it to work, it will be awesome... the anxiety...

-If anyone else has experienced this same problem, please tell...

regards-Fredy
zeldar
10/13/2004 1:43:15 AM
Lookie here :)

letters=new Array();
myString = "Once upon a midnight dreary";

for (i=0; i < myString.length; i++)
_jrh_
10/13/2004 4:17:45 PM
Well, there are several ways of doing it then.

letters = "Once upon a midnight dreary";
letter = new Array();
for (k=0;k<letters.length;k++) {
letter[k] = letters.charAt(k);
robotstyle
10/13/2004 6:51:41 PM
robotstyle
10/13/2004 8:29:46 PM
_jrh_
10/13/2004 8:30:49 PM
AddThis Social Bookmark Button