Hello,
I have problem to load an external text file (small database) and store in an array.
The format and content of the text file (tips.txt) is as below. The empty line is acted as a seperator of the data.
Explanation 1
Formula 1
Explanation 2
Formula 2
Explanation 3
Formula 3
Explanation 4
Formula 4
Explanation 5
Formula 5
What I need?
Element 1 in the array:
Explanation 1
Formula 1
Element 2 in the array:
Explanation 2
Formula 2
etc…
My codes:
My codes are below. I wish to line the empty line as the seperator. However I do not know what seperator should I use? I tried all combination of “\r”, "
" but still no luck.
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest(“tips.txt”));
myLoader.addEventListener(Event.COMPLETE, tipsLoaded);
var tipsArray:Array = new Array();
var tipsContent:String
function tipsLoaded(event:Event):void {
[INDENT]
tipsContent = event.target.data;
//What seperator should I use?
tipsArray = tipsContent.split(“?What?Seperator”);
[/INDENT]
}
Please help.
Thanks and best regards
Alex