PDA

View Full Version : How to manipulate Strings in Flash 4


PogiEnGanda
02-15-2006, 09:14 AM
I mean, what is the equivalent string.charAt() in Flash 4.

How can you do something like these:
String s = "This is statement 1.
This is statement 2."

parse the string with "\n" so it would be stored in an array:
array_0 = "This is statement 1.";
array_1 = "This is statement 2.";

sophistikat
02-21-2006, 07:29 PM
why in gods green earth are you using flash 4?

PogiEnGanda
03-02-2006, 07:55 AM
I need to because actually im running an application through Flash Lite 1.1 player. By the way, I hope this forum has a Flash Lite 1.1 / 2.0 section.

why in gods green earth are you using flash 4?

sophistikat
03-02-2006, 03:39 PM
i don't have flash 4 installed with me but lets give this a shot
myString = "This is statement 1.This is statement 2";
var myArray = myString.split(".");should outputVariable _level0.myString = "This is statement 1.This is statement 2"
Variable _level0.myArray = [object #1, class 'Array'] [
0:"This is statement 1",
1:"This is statement 2"
]

EDIT: Sh**, that wont work; split() was only available until flash 5
EDIT: Give this a read while i try to find the answer for you
http://www.macromedia.com/devnet/devices/articles/as_flashlite.html

sophistikat
03-02-2006, 09:14 PM
Hi Pogi, just finished talking to some web developer in macromedia and he said nope, the string class and its methods weren't introduced until flash 5.

sophistikat
03-03-2006, 05:13 PM
i found this script that helps you brake down a string in flash 4str = "This is a string of stuff!";
delim = "st";
arrName = "arr";
//
//split code: split str on delimeter into an 'array'
copy = str;
len = 0;
dl = length (delim);
if (dl == 0) {
x = 0;
} else {
x = -1;
}
while (++x + dl < length (copy)) {
f = substring (copy, 0, x);
s = substring (copy, x + 1, dl);
e = substring (copy, x + dl + 1, length (copy) - x);
if (s eq delim) {
eval (arrName add (len++)) = f;
copy = e;
if (dl == 0) {
x = 0;
} else {
x = -1;
}
}
}
eval (arrName add (len++)) = copy;
//end split code
//
// loop through 'array'
count = 0;
while (count < len) {
trace (eval ('arr' add count));
count++;
}