Skip navigation
Currently Being Moderated

json.encode not working in Flash CS6?

Jul 15, 2012 5:02 PM

Hey all,

 

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?

 

Cheers.

 
Replies
  • kglad
    61,985 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 15, 2012 5:12 PM   in reply to Bran1010

    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.

     
    |
    Mark as:
  • kglad
    61,985 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 16, 2012 12:56 PM   in reply to Bran1010

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points