Hi I am trying to read data from a file And I want to parse through the data and put it in an array.
The data looks like:
#Coordinates#_*1*2*0_*1*3*1_*2*4*1_*1*5*2 etc...
For each _ there is a new set of coordinates for an object, _*1*2*0 means that object 1 should have xcoordinate 2 and y coordinate 0, the next set is also for obect 1 but then it has moved to coordinate x=3 and y=1 and so on.
I have used the follwoing code to read the data from file:
var myLoader:URLLoader = new URLLoader()
myLoader.dataFormat = URLLoaderDataFormat.TEXT
myLoader.load(new URLRequest("data.txt"))
myLoader.addEventListener(Event.COMPLETE, onDataLoad)
myLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError)
myLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError)
myLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHTTPStatus)
function onDataLoad(evt:Event){
comments_txt.text = evt.target.data; //I put the data in a textfield on the stage just to see that
//I have read the data, its here I assume that I should do anything smart
}
Everything works fine above but I don't know how to parse the data to an dataclass or an array, please help me.
I cannot change the format of the textfile, If I could then I would use VARIABLES instead of TEXT as URLLoaderDataFormat
The data looks like:
#Coordinates#_*1*2*0_*1*3*1_*2*4*1_*1*5*2 etc...
For each _ there is a new set of coordinates for an object, _*1*2*0 means that object 1 should have xcoordinate 2 and y coordinate 0, the next set is also for obect 1 but then it has moved to coordinate x=3 and y=1 and so on.
I have used the follwoing code to read the data from file:
var myLoader:URLLoader = new URLLoader()
myLoader.dataFormat = URLLoaderDataFormat.TEXT
myLoader.load(new URLRequest("data.txt"))
myLoader.addEventListener(Event.COMPLETE, onDataLoad)
myLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError)
myLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError)
myLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHTTPStatus)
function onDataLoad(evt:Event){
comments_txt.text = evt.target.data; //I put the data in a textfield on the stage just to see that
//I have read the data, its here I assume that I should do anything smart
}
Everything works fine above but I don't know how to parse the data to an dataclass or an array, please help me.
I cannot change the format of the textfile, If I could then I would use VARIABLES instead of TEXT as URLLoaderDataFormat