我正在使用as3corelib JSON库并从URLLoader请求中解码一些JSON。然而,我在与JSON.decode抛出一个错误的问题:AS3 JSON.decode抛出#1009错误
TypeError: Error #1009: Cannot access a property or method of a null
object reference. at com.adobe.serialization.json::JSONTokenizer/nextChar() at com.adobe.serialization.json::JSONTokenizer() at com.adobe.serialization.json::JSONDecoder() at com.adobe.serialization.json::JSON$/decode() at Main/drawMap() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete()
我的代码如下:
private function storeAssets(e:Event):void
{
// returned variables from PHP call
var variables:URLVariables = new URLVariables(e.target.data);
assets = JSON.decode(variables.assets);
}
我已经通过我的JSON输入验证器,它总是返回为有效,以便我真的在挠挠我的脑袋。
为什么使用URLVariables? 如果您直接从服务器获取json数据,则不应使用URLVariables,只需获取响应字符串并将其直接传递给JSON.decode – Ben 2011-01-31 01:54:57