0 Replies Latest reply on Apr 24, 2010 9:15 AM by lothar24

    Type error 1034 with charts and tabnavigator

    lothar24

      There seems to be an event name clash in the sdk. Although type error 1034 on chart with selectionMode set to other than "none" has been posted several times, I didn't find an answer.

       

      I have added some small code below that shows the problem. I have used the code from the help files to make sure the problem is not in my own code.

      Start with the example in section "Clearing selections" on http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7bfd.html#WS2d b454920e96a9e51e63e3d11c0bf69084-7bfc and copy it to flash builder 4 project. If this works ok, move it inside a tabnavigator that has a change handler. After this, if you select a point on the chart, you will get a coercion error.

       

      Here is the complete code:

       

      <?xml version="1.0" ?>

      <!--  charts/ClearItemSelection.mxml -->

      <s:Application

         xmlns:fx="http://ns.adobe.com/mxml/2009"

         xmlns:mx="library://ns.adobe.com/flex/mx"

         xmlns:s="library://ns.adobe.com/flex/spark"

         creationComplete="initApp();srv.send();"

         height="600" width="543">

       

      <fx:Declarations>

      <!-- View source of the following page to see the structure of the data that Flex uses in this example. -->

      <mx:HTTPService id="srv" url="http://aspexamples.adobe.com/chart_examples/expenses-xml.aspx"/>

      <!-- To see data in an HTML table, go to http://aspexamples.adobe.com/chart_examples/expenses.aspx --> 

      </fx:Declarations>

       

      <fx:Script>

      <![CDATA[

      import flash.events.KeyboardEvent;

       

      import mx.core.FlexGlobals;

      import mx.events.IndexChangedEvent;

       

      private function initApp():void {

      FlexGlobals.topLevelApplication.addEventListener(KeyboardEvent.KEY_UP, keyHandler);

      }

       

      // Clears all chart items selected when the user presses the ESC key.

      private function keyHandler(event:KeyboardEvent):void {

      var curKeyCode:int = event.keyCode;

      if (curKeyCode == 27) { // 27 is the keycode value for ESC

      myChart.clearSelection();

      }

      }

       

      protected function tabnavigator1_changeHandler(event:IndexChangedEvent):void

      {

      trace ("change");

      }

       

      ]]>

      </fx:Script>

       

      <s:layout>

      <s:VerticalLayout/>

      </s:layout>

      <mx:TabNavigator width="445" height="347" change="tabnavigator1_changeHandler(event)">

      <s:NavigatorContent label = "plot" height="100%" width="100%">

      <s:layout>

      <s:VerticalLayout/>

      </s:layout>

      <mx:PlotChart id="myChart"

        height="207"

        width="350"

        showDataTips="true"

        dataProvider="{srv.lastResult.data.result}"

        selectionMode="multiple">

      <mx:series>

      <mx:PlotSeries id="series1"

         xField="expenses"

         yField="profit"

         displayName="Expenses/Profit"

         selectable="true"/>

      <mx:PlotSeries id="series2"

         xField="amount"

         yField="expenses"

         displayName="Amount/Expenses"

         selectable="true"/>

      <mx:PlotSeries id="series3"

         xField="profit"

         yField="amount"

         displayName="Profit/Amount"

         selectable="true"/>

      </mx:series>

      </mx:PlotChart>

      <mx:Legend dataProvider="{myChart}" width="200"/> 

      <s:Label text="Press ESC to clear selection."/>    

      </s:NavigatorContent>

       

      <s:NavigatorContent  label="tab2" height="100%" width="100%">

      <s:layout>

      <s:VerticalLayout/>

      </s:layout>

      <mx:DateChooser/>

      </s:NavigatorContent>

      </mx:TabNavigator>

      </s:Application>