Recently, I write ActionScript for one Flash Lite 1.1 movie . I was stuck in Flash Lite 1.1 problem - there is no standart realization of Text / String functions. I have found the help on one interesting russian blog (http://flashweb.sabiostar.com/). Now I wish to share with you some solutions (with my corrections) :
(you can use call() on main scene to simulate these functions)
1. Make a string uppercase
// input_str set by calling script
output_str = “”;
str_length = length(input_str);
for (i=1; i< (str_length+1); i++)
{
let = substring(input_str, i, 1);
if (ord(let)>96 && ord(let)<123){
let = chr(ord(let)-32);
}
output_str = output_str add let;
}
2.Make a string lowercase
// input_str set by calling script
output_str = “”;
str_length = length(input_str);
for (i=1; i< (str_length+1); i++)
{
let = substring(input_str, i, 1);
if (ord(let)>64 && ord(let)<91){
let = chr(ord(let)+32);
}
output_str = output_str add let;
}
3.Find position of first occurrence of char in the string
// input_str set by calling script
resPos = -1; // position of the char theChr
str_length = length(input_str);
for (i=1; i< (str_length+1); i++)
{
let = substring(input_str, i, 1);
if (let eq theChr) {
resPos = i;
break;
}
}
4. Replace all occurrences of the search string with the replacement string
output_str = “”;
input_length = length(input_str);
search_length = length(search_str);
for (i=1; i< (input_length+1); i++)
{
inputChr = substring(input_str, i, 1);
searchChr = substring(search_str, 1, 1);
if(inputChr eq searchChr) // if first character matches, attempting to match the rest of search_str
{
matchFound = true;
pos = i;
k = 1;
for (j=pos; j< (search_length+pos); j++)
{
searchChr = substring(search_str, k++, 1);
matchChr = substring(input_str, j, 1);
if (!(searchChr eq matchChr)) {
matchFound = false;
break;
}
}
if (matchFound) {
//actual replace
i += search_length-1;
output_str = output_str add replacement_str;
}
else{
output_str = output_str add inputChr;
}
}
else{
output_str = output_str add inputChr;
}
}
Certainly, all it is not necessary, if you create movie in Flash Lite 2.x. Because, in Flash Lite 2.x you can use functions of the String class (such as String.toLowerCase() ,String.toUpperCase() , etc.)



Ciao
really useful functions, great work!
Alesssandro
[...] HardCoreDev posted some great functions to manipulate strings. Very interesting. It would be great to create some components out of these functions. [...]
This file has been copied to that server from this site (original file):
Link to original file:
http://richardleggett.co.uk/downloads/flashlite/string/StringFunctions.zip
These are the String functions explained in the new book:
http://www.flashmobilebook.com
Hello Richard,
thank you for real source of this nice solution