How can I resolve "Access of undefined property JSON?"

331 Views Asked by At

This should be simple, but google has failed me (more likely I didn't ask it nicely).

Using FlexBuilder 3, I just added code to do some JSON stuff. When I compile/debug from FlexBuilder everything works wonderful. When I try to compile using MXMLC I get the error "Access of undefined property JSON."

Some details;

In FlexBuilder I am using SDK - Flex 3.5.

The compile command line is:

mxmlc -load-externs=report.xml -warnings=false myModule.mxml

The import in the module is:

import com.adobe.serialization.json.JSON;

I suspect it is a library I need to include on the command line, but it eludes me.

2

There are 2 best solutions below

4
Mr. Phantom On

Several years ago the ActionScript 3 standard library didn't include a native JSON parser and we had to import an external one manually. Nowadays the AS3 standard library has a prebuilt one that works almost exactly the same.

You have two options:

  1. Download the as3corelib swc and put it into your libs folder inside your project.

  2. Overlay a recent version of the AIR SDK into your Flex SDK.

For the second step you need to download the AIR SDK from here, be very careful with the version you download. You need to download the AIR SDK for Flex developers.

Your Flex SDK is located inside the sdks folder where Flex Builder is installed.

Once you download it, unzip it and merge all its contents with your Flex SDK folder (if asked to overwrite, choose Yes).

Don't forget to make a backup of your Flex SDK incase something goes wrong.

0
Paul Stearns On

Mr. Phantom helped me figure out the mystery. I already had the as3corelib swc file in my library path in FlexBuilder, and in the compile of the main application of the system, but I did not have it in the compile of the modules, of which this is one.

When I initially tried to fix it I used;

-library-path="I:\MyApp\libs"

which caused other errors, when I changed it to;

-library-path+="I:\MyApp\libs"

Everything worked swimmingly. Please note th "+" before the "=".