I just updated to CS6 last week and tried to run one of my applications that worked fine in 5.5.
I'm now getting an error when I try to compile it. The error is 'Call to a possibly undefined method encode through a reference with static type Class'.
The error coming from this line:
var myJson:String = JSON.encode(myData);
Importing the package com.adobe.serialization.json.JSON, so everything should be fine?
Is there a new way to encode/decode JSON data in CS6? Is there a fix around, or am I just missing something completely?
if you're publishing for fp 11 or better you will use the native flash JSON class. in that case, you should use the static parse() and stringify() methods.
if you're publishing for less than fp11, you can use mike chambers JSON class (https://github.com/mikechambers/as3corelib) that has static encode() and decode() methods.
Yeah, I'm using Mike Chambers JSON class. Since I am publishing for fp 11 or better, this then means that it won't work at all? Won't even give me the choice?
Seems odd that it would make that jump from CS5.5 to 6, but I guess I will have to learn how to do use the native class!
if you're publishing for fp11 or better, you are NOT using mike chambers class (even though you may be importing it and have it in your library path). you are trying to use two different classes, both named JSON and the native flash class will be the one used by the compiler, not the one you want.
you only need to re-read my above post. if you want to use fp11, use the parse() and stringify() methods. they work the same as chamber's decode() and encode() methods.
Europe, Middle East and Africa