factornine blog

Tuesday, February 20, 2007

Displaying the apostrophe ‘ symbol, loaded from an XML file.

Displaying the apostrophe ‘ symbol, loaded from an XML file where a fieldfield is loaded dynamically with Action Script.

Adapted from a flashcoders post.

1. Firstly, the apostrophe within the xml is written as ' within the correct tags. Eg:
< mainText > The twins' information... < /mainText >
2. Assume there is a function called replaceText which creates a string from the XML file, within the ActionScript.
newText = replaceText(newText);
3. Set the string of the asset on the stage via a function called fixApostrophes:
tmpCurrentPage.alert.text = fixApostrophes(newText);
4. The fixApostrophes function:
function fixApostrophes(theHeaderText){

theHeaderString = String(theHeaderText);

if(theHeaderText.indexOf("'") != -1) {
theHeaderArray = theHeaderString.split("'");
theHeaderText = theHeaderArray.join("\'");
}

return theHeaderText;
}
5. That's it!

0 Comments:

Post a Comment

<< Home