Load Text Files Into Flash · 1330 days ago
The LoadVars class is good for loading variable / value pairs and XML class is good for loading structured data. But there is an easy way to load an entire text file as it is formatted without urlencoding it or structuring it in an xml file.
Look up XML.onData in Flash; it’s right there in the documention.
Here is the code from this simple example:
testXML = new XML();
testXML.ignoreWhite=true;
testXML.onData = myData;
function myData(contents) {
if (contents == undefined) {
mText="Not found";
} else {
mText=contents;
}
}
testXML.load("test.txt");
“onData” is invoked before flash parses the xml data. “contents” is the raw text from the file.