简体   繁体   中英

I need to import something in order to use JSON in AS3?

When using the following codeline:

var myjson:Object = JSON.parse("path_to_my.json");

I got the following error:

1120: Access of undefined property JSON.

I had to import any package in order to use the JSON.parse?

Thank you!

[with: Flash CS5 (11.0.0.485), AS3]

JSON is built in to the ActionScript default package starting at Flash Player 11, and is notably higher performance than 3rd party serializers.

With Flash CS5, you need to update the target Flash Player from the Publish Settings. By default it will target up to Flash Player 10.2.

Adobe has a blog regarding Adding Flash Player 11 support to Flash Pro CS5 and CS5.5 .

At that page you will find an extension (MXP) install as well as manual instruction of updating Flash Player to 11.

Load CS5 or CS.5 MXP with Adobe Extension Manager, and you will be able to target Flash Player 11.0 from your Publish Settings:

发布设置

Note that JSON parse takes an object, and not a path to a file. Your code should give Error #1132: Invalid JSON parse input.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM