0 Replies Latest reply on Feb 16, 2012 9:12 AM by RichardSmithONS

    Sending XML to an HTML page in AS3


      I'm working on an a Flex 3 application to generate XML to use in Fusion Charts Free.


      So that the user can preview the chart, I'm currently sending the XML to an HTML page with runs the chart SWF using navigateToURL with the XML appended to the query string. The HTML page captures the query string with Javascript and supplies the XML to the chart.


      <script type="text/javascript">

         var xmlstring = getParameterByName('xml');

         var chart = new FusionCharts("FCF_Column2D.swf", "ChartId", "900", "600");



         function getParameterByName(name) {

              var match = RegExp('[?&]' + name + '=([^&]*)')


              return match && decodeURIComponent(match[1].replace(/\+/g, ' ')); 




      This works fine in Firefox but I have problems with IE - the maxium URL length limits the amount of data, and IE9 removes the query string if in protected mode, and also requires it to be URL encoded. I try to get round this with the actionscript below.


      var pageurl:String = chartpage + ".html";
      var appName:String = ExternalInterface.call( "function getAppName(){ return navigator.appName; }" );
      var agentName:String = ExternalInterface.call( "function getAppName(){ return navigator.userAgent; }" );
      var qs:String = qxml;

      // IE cannot cope with more than 2083 chars in URL
      // IE9 requires escaping and needs to be not in protected mode

      if (appName == "Microsoft Internet Explorer")
         if (agentName.indexOf("MSIE 9") > -1)
          qs = encodeURI("?xml="+qxml);
          if (qs.length > 2000)
          Alert.show('Data is more than 2000 bytes, too much to pass to Internet Explorer on the query string. Choose less data or use a different browser.', 'Fusion Chart Generator', mx.controls.Alert.OK);
          var urlRequestIE:URLRequest = new URLRequest(pageurl+qs);

        var urlRequest:URLRequest = new URLRequest(pageurl+"?xml="+qxml);


      Is there a better way of doing this?