actionscript 3 and JSON

后端 未结 1 2025
野趣味
野趣味 2021-01-04 10:40

I\'ve been trying to get JSON working with AS3 for a while now, but to no avail. I keep getting the following error when I get the JSON back:

TypeError: Error #1034

1条回答
  •  北荒
    北荒 (楼主)
    2021-01-04 11:21

    You were correct when you had the jsonData variable as an Object. To iterate through all the properties of that variable you could just do something like this:

    var jsonData:Object = JSON.decode(loader.data);
    for (var i:String in jsonData)
    {
        trace(i + ": " + jsonData[i]);
    }
    

    If you wanted to check if the object contained a specific property you could use something like:

    var hasFooProperty:Boolean = jsonData.hasOwnProperty("fooProperty");
    

    0 讨论(0)
提交回复
热议问题