Haven't tested it but where you call eliminateSpaces inside the function,
you don't save the result...
----- Original Message -----
From: "Mendelsohn, Michael" <[EMAIL PROTECTED]>
To: <flashcoders@chattyfig.figleaf.com>
Sent: Tuesday, July 24, 2007 9:22 PM
Subject: [Flashcoders] Returning a String fails
Hi list...
I've written a simple routine to eliminate spaces from a user entered
string. But, it won't return the string. I'm sure it's something
silly. Can anyone shed light?
- MM
function eliminateSpaces(phrase:String):String {
var foundSpace = phrase.indexOf(" ");
if (foundSpace != -1) {
phrase = String(phrase.substring(0, foundSpace) +
phrase.substring(foundSpace + 1));
if (phrase.indexOf(" ") != -1) {
eliminateSpaces(phrase);
} else {
trace("output: " + phrase);
return phrase;
}
}
}
var s:String = eliminateSpaces("moe and larry and curly");
trace(s);
/* RESULT:
output: moeandlarryandcurly
Undefined
*/
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com