Skip to main content
Inspiring
October 4, 2011
Answered

[AIR 3.0] New JSON functionality doesn't work in FlashPro: Error #1065: Variable JSON is not defined

  • October 4, 2011
  • 14 replies
  • 19327 views

After upgrading the AIR SDK to 3.0 in Flash Professional CS5.5 I've found some problems.

First, the JSON class in the as3corelib.swc library now throws a couple of compile errors:

1061: Call to a possibly undefined method decode through a reference with static type Class.

1172: Definition com.adobe.serialization.json:JSON could not be found.

At first I was completely puzzled, since I had the proper "import com.adobe.serialization.json.JSON;" reference,

and I had the "as3corelib.swc" referenced in my ActionScript Properties, so how could that not be found?

Then, I found out that's because it conflicts with the new internal JSON class included with AIR 3.0

(maybe it should have been called something else, to avoid conflicts with Adobe's own as3corelib library).

The new native JSON class doesn't have the decode() method. Now it's called parse()

Ok, so I've tried using the new JSON class, but after changing decode() with parse() and removing

the "import com.adobe.serialization.json.JSON;" reference, Flash tells me that "Variable JSON is not defined".

Really? The JSON class is showing in the Flash Builder code completion popup,

complete with its all-new parse() and stringify() methods! So why does it say it's not defined?

Also, my SWF file gets compiled with no errors at all, so that verifies that the new 3.0 libraries are in place.

I only get the "JSON is not defined" error at runtime in ADL, not at compile time. Why?

In order to upgrade to the AIR 3.0 SDK, I've followed this guide:

http://kb2.adobe.com/cps/908/cpsid_90810.html

I know that's about upgrading to AIR 2.7, but I suppose the steps to upgrade to AIR 3.0 would be very similar,

only with the AIR3.0 SDK package, instead of 2.7.

I also took care to type version="13" in all the XMLs, instead of version="12" as stated in that guide, which is meant for 2.7.

Also, I followed this advice about adding -swf-version=13 in the Project Properties window in Flash Builder:

http://blogs.adobe.com/cantrell/archives/2011/08/how-to-use-the-air-3-beta-sdk.html

But that doesn't seem to make a difference, since, even though I use Flash Builder for code editing (which is usually used for Flex),

my project is a Flash Professional project, not a Flex one, and when testing the project, Flash Builder runs Flash Professional

to compile and then runs adl.exe (it's the same as if you click the option "Control / Test movie / in AIR Debug Launcher (Mobile)" inside Flash Pro).

In the "ActionScript Settings" window in Flash Professional, I also have the proper airglobal.swc referenced (from the AIR 3.0 SDK),

and the same airglobal.swc is referenced in Flash Builder as well (in "Referenced Libraries"), to get proper code completion.

I've tried all sorts of things to try to get it to work, but no luck. Still get the "JSON is not defined" error at runtime.

I'm starting to get desperate about this. I'm going to have to revert back to AIR 2.7.1, to stop wasting time on this issue.

BTW, I'm also having another unrelated problem (though maybe it happens because of the same reason as the other problem).

Now Flash Builder underlines the getTime() method in my code, as if it no longer were a method of a Date class instance.

I have a line where I ask for the timestamp like this:

ts = new Date().getTime();

That has worked perfectly fine up until now with AIR 3.0.

Now, when hovering the mouse cursor over the orange "(?)" icon that appears at the left, Flash Builder tells me

"Access of undefined property getTime". Why?

The AS3 documentation doesn't say anything about getTime() getting deprecated of anything of the sort:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Date.html

In fact, in the code completion popup that Flash Builder shows, now there isn't any mention

of get or set methods, as you can see here:

http://img836.imageshack.us/img836/4793/dateinstancepopup.png

I suppose I can use the .time property instead of .getTime() but I don't know why I'm not getting all the methods I had available before.

Any ideas why all this is happenning? Specially the dreaded "JSON is not defined" error.

This topic has been closed for replies.
Correct answer OMA2k

Well, after much tinkering, I think I've finally found a way to finally make it work!.

I've created some modified XML files with the profiles needed for AIR 3.0 and after a lot of tries, it finally works!

I've uploaded them here: http://www.mediafire.com/?d5e761frl5px4

These are the steps needed to get AIR 3.0 running properly:

  1. Put all three files into the folder "c:\Program Files (x86)\Adobe\Adobe Flash CS5.5\Common\Configuration\Players"
  2. Then, make sure you've unzipped the AIR 3.0 SDK into the folder "c:\Program Files (x86)\Adobe\Adobe Flash CS5.5\AIR3.0" Do not overwrite the contents of the "AIR2.6" folder, as suggested by the "Overlay AIR SDK" article (linked in the above post). It gave me problems. It's best to use a different separate folder. My XML files point to that new "AIR3.0" folder.
  3. Inside the folder "c:\Program Files (x86)\Adobe\Adobe Flash CS5.5\Common\Configuration\ActionScript 3.0" create a new folder named "AIR3.0". Inside that folder, copy the file "airglobal.swc" located at "c:\Program Files (x86)\Adobe\Adobe Flash CS5.5\AIR3.0\frameworks\libs\air".
  4. Finally, you will have to keep the file "descriptor-sample.xml" in the "c:\Program Files (x86)\Adobe\Adobe Flash CS5.5\AIR2.6\samples" folder, but change the xmlns attribute to "http://ns.adobe.com/air/application/3.0"

Yes, you have to change that inside the AIR2.6 folder even if the SDK has been put into AIR3.0. That's because of how the publish settings work in Adobe Flash. It's hardcoded into a DLL, so that can't be changed. Not very intuitive.

I think AIR SDK installations should be a lot more straightforward than this! I know Adobe AIR is meant for developers, not for final users, but still, all these not very well documented upgrade procedures are a pain in the ass. I've wasted A LOT of hours in this (more than half a day), with what should have been a straightforward upgrade!

Adobe should make a SDK installer so we do not have to be tinkering with all these error-prone procedures each time a new update is released!

Well, I hope those XML files are useful to somebody and avoids further frustration.

Regards,

OMA2k

PD: BTW, I still have the .getTime() issue described in my above post, but it's not very important,

since I can still use the .time property. Still, it puzzles me why this is happening.

14 replies

9999pippoflash
Inspiring
June 20, 2012
Participant
November 11, 2011

Thanks so much for this, huge time saver.

About to update to AIR 3.1, any suggestions?

OMA2kAuthor
Inspiring
November 11, 2011

Hello, I've uploaded the upgraded files for AIR 3.1 here:

http://www.mediafire.com/?2btbk0x9i9gdy

You can compare the XML files for AIR 3.0 and AIR 3.1 and you'll see

it's actually just a few easy modifications.

To install AIR 3.1 just follow the same steps posted above, but changing all instances of "3.0" to "3.1"

All three XML files go here:

c:\Program Files (x86)\Adobe\Adobe Flash CS5.5\Common\Configuration\Players

Remember that you can't have several XML profiles for "AIR for iOS" in the same folder.

So delete or move the old files "iOS_AIR3_0.xml" and "AiriPhone.xml", if you have them.

On the other hand, you can have several XML profiles for Android and Desktop,

so you can leave the old "Android_AIR3_0.xml" and "AdobeAIR3_0.xml" files if you wish.

Hope this helps.

Participant
November 15, 2011

Thanks so much, really helpful!  If you're ever in the UK near Bristol / Hereford hit me up and i'll get you a beer =)

Cheers,

Matt / MSFX

October 17, 2011

THANK YOU!

OMA2kAuthor
Inspiring
October 17, 2011

Glad to see this helped someone

OMA2kAuthorCorrect answer
Inspiring
October 5, 2011

Well, after much tinkering, I think I've finally found a way to finally make it work!.

I've created some modified XML files with the profiles needed for AIR 3.0 and after a lot of tries, it finally works!

I've uploaded them here: http://www.mediafire.com/?d5e761frl5px4

These are the steps needed to get AIR 3.0 running properly:

  1. Put all three files into the folder "c:\Program Files (x86)\Adobe\Adobe Flash CS5.5\Common\Configuration\Players"
  2. Then, make sure you've unzipped the AIR 3.0 SDK into the folder "c:\Program Files (x86)\Adobe\Adobe Flash CS5.5\AIR3.0" Do not overwrite the contents of the "AIR2.6" folder, as suggested by the "Overlay AIR SDK" article (linked in the above post). It gave me problems. It's best to use a different separate folder. My XML files point to that new "AIR3.0" folder.
  3. Inside the folder "c:\Program Files (x86)\Adobe\Adobe Flash CS5.5\Common\Configuration\ActionScript 3.0" create a new folder named "AIR3.0". Inside that folder, copy the file "airglobal.swc" located at "c:\Program Files (x86)\Adobe\Adobe Flash CS5.5\AIR3.0\frameworks\libs\air".
  4. Finally, you will have to keep the file "descriptor-sample.xml" in the "c:\Program Files (x86)\Adobe\Adobe Flash CS5.5\AIR2.6\samples" folder, but change the xmlns attribute to "http://ns.adobe.com/air/application/3.0"

Yes, you have to change that inside the AIR2.6 folder even if the SDK has been put into AIR3.0. That's because of how the publish settings work in Adobe Flash. It's hardcoded into a DLL, so that can't be changed. Not very intuitive.

I think AIR SDK installations should be a lot more straightforward than this! I know Adobe AIR is meant for developers, not for final users, but still, all these not very well documented upgrade procedures are a pain in the ass. I've wasted A LOT of hours in this (more than half a day), with what should have been a straightforward upgrade!

Adobe should make a SDK installer so we do not have to be tinkering with all these error-prone procedures each time a new update is released!

Well, I hope those XML files are useful to somebody and avoids further frustration.

Regards,

OMA2k

PD: BTW, I still have the .getTime() issue described in my above post, but it's not very important,

since I can still use the .time property. Still, it puzzles me why this is happening.

OMA2kAuthor
Inspiring
October 6, 2011

I've realized the XML for iOS didn't work properly. I've uploaded a new iOS_AIR3_0.xml file replacing the old one in the same MediaFire URL linked above (you'll see it has newer date than the other files).

The problem with the old XML was that it had a <name> other than "AIR for iOS" (I had written "AIR 3.0 for iOS" to differentiate from the old version). It seems Adobe Flash CS5.5 looks for this string. If it's "AIR for iOS", then Flash presents the appropriate options for iOS in the "AIR for iOS Settings" window, but if that string is anything else than "AIR for iOS", then the settings shown are the AIR desktop ones. The only problem now is that you can't have 2 iOS options coexist (2.7 and 3.0) so you'll have to move the "AiriPhone.xml" file out of that folder to use the new XML for AIR 3.0 for iOS.

So you're changing the application behaviour based on the content of a string rather than an ID?! What about localization? I haven't tried localized versions of Flash CS5.5, but I suspect that string can't be translated, or else that settings window won't work.

So the AIR SDK has some hardcoded folder names in its DLLs, and Flash Pro CS5.5 changes AIR settings behaviour based on an English string which is shown to the user in the menus, instead of using an ID or any other variable... Not very polished, I think.

Inspiring
October 8, 2011

Unbelievable!

Hey Adobe, wake-up!!!  We need a formal procedure to overlay 3.0 over CS5.5, plz.