Greetings,
i’m trying to figure out a way to read strings from a JSON formatted txt and put them into text fields.
So far this is what i’ve come up with:
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest();
request.url = "demo.txt";
loader.load(request);
loader.addEventListener(Event.COMPLETE, decodeJSON);
function decodeJSON(event:Event):void{
var loader:URLLoader = URLLoader(event.target);
var People:Object = JSON.parse(loader.data);
//text boxes
qfname01.text = People[0].playerName;
qfscore01.text = People[0].playerScore;
}
Basicly i’m using Object instead of Array because the object is a collection of items where each is assigned to a specific string.
This is the JSON txt file:
{"playerName":"Jonny", "playerScore":"32" ,
"playerName":"Jimbo", "playerScore":"12" ,
"playerName":"Mark", "playerScore":"14" ,
}
When i export it i get no error. However, i get the 1132 saying the input parser is not valid when i launch it.
Any ideas? =)