Hi Stackers, so I have a JSON link that contains a couple of nodes (not sure what you call them in JSON) that I need to put into arrays in ActionScript, but I'm still having trouble trying to trace out all the specific node content.
I found a similar question here, but the fix just showed how to trace out the entire JSON file (which shows up in my output window as [object Object],[object Object],[object Object],...)
first node: {"captions":[{"content":"[hello world] ","startTime":0,"duration":4000}
My code:
private function onCaptionsComplete( event:Event ):void
{
//var jsonObj:Object = JSON.decode(event.target.data);
//var englishCaptionsObject = jsonObj;
var englishCaptionsObject:Object = JSON.decode(cc_loader.data);
captionsContent.push(englishCaptionsObject);
trace("captionsContent = "+captionsContent);
for (var i:String in englishCaptionsObject)
{
trace(i + ": " +englishCaptionsObject[i]);
trace(i + ": " +englishCaptionsObject[i].content);
trace(i + ": " +englishCaptionsObject[i].content[i]);
trace(i + ": " +englishCaptionsObject[i].startTime[i]);
}
}
When I run it here are my traces below:
captionsContent = [object Object]
captions: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
captions: undefined
TypeError: Error #1010: A term is undefined and has no properties.
What I would like to be able to do is put the content data into the captionsContent Array, and the startingTime into a startingTime Array, same with the duration data.
Any tips?