0 Replies Latest reply on Jun 28, 2011 12:10 AM by majiaqi

    Couldn't pass JSON array by flashvar from js to Flex4

    majiaqi

      Hi all:

          I'm a new for Flex, and i've work on this for a whole day, really drove me crazy..

       

          In generated html file under bin-debug, i add this:

          var flashvars = {columnData1 : '[{fieldx:"2011-4-1", fieldy:19, label:"This is label for 2011-4-1"},{fieldx:"2011-4-1", fieldy:19, label:"This is label for 2011-4-1"}]'};

       

          Then pass flashvars to swfobject.embedSWF()

       

          In xmxl:

       

          import com.adobe.serializers.json.JSONDecoder;

          protected function simpleChart_creationCompleteHandler(event:FlexEvent):void
         {
          /* From wrapper */
          var decoderJSON : JSONDecoder = new JSONDecoder();
          Alert.show("JSON String : " + FlexGlobals.topLevelApplication.parameters.columnData1);

         ........

       

         Run this in Firefox, it printed the whole JSON string to screen.

         But if run in IE, it printed this JSON String : [{fieldx:, which means something wrong with the Double Quotation Marks. Then i tried to switch single and double quotation marks in JSON string, it turned out that JSONDecoder.decode couldn't work with that. Also tried to remove the single quoation marks outside the array, this was printed : JSON String : [object Object],[object Object] , and i have no idea how to bind this to dataProvider or transfer them to ArrayCollection..

         And i also replaced double quotationmarks with escape character(" " '), it could recieve the string in IE, but failed in Firefox...

       

         What should i do with this JSON array..?