0

tI have a file create with Flash Builder and the Flex 4.1 SDK which compiles fine in Flash Builder 4.5.1 but fails to compile with the command-line MXMLC (run via SublimeText 2 build system file). It doesn't like this line:

var dataString:String = JSON.encode(packagedData);

with the error

Error: Access of undefined property JSON.

I realize what the error means, but why does in work inside Builder but not in the command line? Is there a library I need to include if I'm building it this way?

ketan
  • 19,129
  • 42
  • 60
  • 98
Steve
  • 14,401
  • 35
  • 125
  • 230
  • 3
    JSON Wasn't added to the Flash Player until after Flex 4.1 was released. You'll probably have to update the PlayerGlobals and/or AIR SDK of your SDK if you want to use JSON. It'll be easier to just use a more recent SDK, such as Flex 4.6 or Apache Flex 4.8 . – JeffryHouser Dec 20 '12 at 15:42
  • Why does it compile and work fine when compiled via Flash Builder 4.5.1 (using the 4.1 sdk as a build target)? – Steve Dec 20 '12 at 16:01
  • 1
    Perhaps because it is targeting another FlashPlayer version. Maybe FB adds the correct PlayerGlobal.swc to the build path when you select a specific player version. – RIAstar Dec 20 '12 at 16:18
  • 1
    JSON is specific to FP11+ I bet in FB, FP11 is selected as player target, so make sure you manually tell the compiler to target player 11 and it should work fine – Jason Reeves Dec 20 '12 at 17:05
  • pardon my ignorance, but when issuing the mxmlc command how do I target a player version? – Steve Dec 20 '12 at 20:55
  • swf-version=int [See this doc on how to use it](http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7a92.html) or target-player [See this doc](http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7ee0.html) – Jason Reeves Dec 20 '12 at 21:13

0 Answers0