1 Reply Latest reply on Feb 15, 2007 5:26 PM by munkybot

    Some chart elements fails when using FABridge

    hchen416
      Hi,

      I hit the following error when trying to create a chart using JavaScript and FABridge:

      #0: function createChart() in < http://localhost:8080/fabridge2/samples/FABridgeSample4.html> line 39
      037: var flexApp = FABridge.example.root();
      038: if (flexApp.getPanel().getChildByName("chart") == null) {
      039: var chart = FABridge.example.create("mx.charts.LineChart");
      040: chart.setName("chart");
      041: var dtAxis = FABridge.example.create("mx.charts.DateTimeAxis");
      Continuing from breakpoint.
      #0: function anonymous(className=string:"mx.charts.LineChart") in < http://localhost:8080/fabridge2/src/bridge/FABridge.js> line 233
      233: return this.deserialize(this.target.create(className));
      #0: function anonymous(packedValue=string:"__FLASHERROR__||Error #1065: Variable LineChart is not defined.") in < http://localhost:8080/fabridge2/src/bridge/FABridge.js> line 472
      472: var result;
      #0: function anonymous(packedValue=string:"__FLASHERROR__||Error #1065: Variable LineChart is not defined.") in < http://localhost:8080/fabridge2/src/bridge/FABridge.js> line 474
      474: var t = typeof(packedValue);
      #0: function anonymous(packedValue=string:"__FLASHERROR__||Error #1065: Variable LineChart is not defined.") in < http://localhost:8080/fabridge2/src/bridge/FABridge.js> line 475
      475: if (t == "number" || t == "string" || t == "boolean" || packedValue == null || packedValue == undefined)
      #0: function anonymous(packedValue=string:"__FLASHERROR__||Error #1065: Variable LineChart is not defined.") in < http://localhost:8080/fabridge2/src/bridge/FABridge.js> line 477
      477: result = this.handleError(packedValue);
      #0: function anonymous(value=string:"__FLASHERROR__||Error #1065: Variable LineChart is not defined.") in < http://localhost:8080/fabridge2/src/bridge/FABridge.js> line 533
      533: if (typeof(value)=="string" && value.indexOf("__FLASHERROR")==0)
      #0: function anonymous(value=string:"__FLASHERROR__||Error #1065: Variable LineChart is not defined.") in < http://localhost:8080/fabridge2/src/bridge/FABridge.js> line 535
      535: var myErrorMessage = value.split("||");
      #0: function anonymous(value=string:"__FLASHERROR__||Error #1065: Variable LineChart is not defined.") in < http://localhost:8080/fabridge2/src/bridge/FABridge.js> line 536
      536: if(FABridge.refCount > 0 )
      #0: function anonymous(value=string:"__FLASHERROR__||Error #1065: Variable LineChart is not defined.") in < http://localhost:8080/fabridge2/src/bridge/FABridge.js> line 540
      540: throw new Error(myErrorMessage[1]);

      I was able to create a typical ColumnChart with no problem. But the FABridge appears to fail to recognize some
      classes such as "mx.charts.LineChart" and "mx.charts.DateTimeAxis".

      Here is my HTML code:

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

      <!--
      Copyright 2006 Adobe Systems Incorporated

      Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
      to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
      and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

      The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.


      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
      OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

      -->
      <html>
      <head>
      <title>Flex-AJAX Bridge Example</title>
      <script src="../src/bridge/FABridge.js" ></script>
      <script src="FABridgeSample.js" ></script>
      <script>

      function createChart() {
      var flexApp = FABridge.example.root();
      if (flexApp.getPanel().getChildByName("chart") == null) {
      var chart = FABridge.example.create("mx.charts.LineChart");
      chart.setName("chart");
      var dtAxis = FABridge.example.create("mx.charts.DateTimeAxis");
      chart.setHorizontalAxis(dtAxis);
      var s1 = FABridge.example.create("mx.charts.series.LineSeries");
      s1.setXField("Date");
      s1.setYField("Px");
      chart.setSeries( [s1] );
      chart.setWidth(400);
      chart.setHeight(300);
      flexApp.getPanel().addChild(chart);
      }
      }

      function fillData1() {
      var flexApp = FABridge.example.root();
      var chart = flexApp.getPanel().getChildByName("chart");
      var dp = ........
      chart.setDataProvider(dp);

      }

      </script>
      </head>
      <body scroll="no">
      <input type="button" onClick="createChart();return false;" value="Render Chart" />
      <input type="button" onClick="fillData1();return false;" value="FillData1" />
      <div id="container">
      <div id="flashoutput">
      <noscript>
      <object id="flexApp" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,5,0,0" height="800" width="800">
      <param name="flashvars" value="bridgeName=example"/>
      <param name="src" value="app.swf"/>
      <embed name="flexApp" pluginspage=" http://www.macromedia.com/go/getflashplayer" src="app.swf" height="400" width="400" flashvars="bridgeName=example"/>
      </object>
      </noscript>
      <script language="javascript" charset="utf-8">
      document.write('<object id="flexApp" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,5,0,0" height="800" width="800">');
      document.write('<param name="flashvars" value="bridgeName=example"/>');
      document.write('<param name="src" value="app.swf"/>');
      document.write('<embed name="flexApp" pluginspage=" http://www.macromedia.com/go/getflashplayer" src="app.swf" height="500" width="600" flashvars="bridgeName=example"/>');
      document.write('</object>');
      </script>
      <br>
      <br>
      </div>
      </div>
      </body>
      </html>

      Your help is greatly appreciated. Thanks.

      Regards,
      Howard
        • 1. Re: Some chart elements fails when using FABridge
          munkybot
          make sure you import the appropriate classes in your MXML file and reference them at least once. If you don't reference the classes, the compiler will 'optimize' by throwing out the classes not being used...


          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application layout="absolute" width="100%" height="100%" frameRate="12" pageTitle="Graph Sample" xmlns:mx=" http://www.adobe.com/2006/mxml">
          <fab:FABridge xmlns:fab="bridge.*" />
          <mx:Script>
          <![CDATA[
          import mx.charts.*;
          import mx.charts.series.*;
          import mx.charts.effects.*;
          import mx.controls.Alert;
          public var refs:Array = [ColumnChart, ColumnSeries, BarChart, BarSeries, LineChart, LineSeries, PieChart, PieSeries, SeriesInterpolate, DateTimeAxis, Legend, Alert];
          ]]>
          </mx:Script>
          </mx:Application>