2 Replies Latest reply on Mar 23, 2007 12:46 PM by ezschneids01

    Populating Column Chart from XML file

    ezschneids01

      I'm fairly new to Flex programming, I'm attempt to take an XML file I created out of a SQL database and use it to populate a column chart in flex. However I receive the following error:

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at ColChartTest/::resultHandler()
      at ColChartTest/__srv_result()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.rpc.http.mxml::HTTPService/ http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
      at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::resultHandler()
      at mx.rpc::Responder/result()
      at mx.rpc::AsyncRequest/acknowledge()
      at ::DirectHTTPMessageResponder/completeHandler()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at flash.net::URLLoader/flash.net:URLLoader::onComplete()

      I'm using an HTTPservice to call the XML file. If you could point me in the right direction as to where I might be going wrong it would be very appreciated. Thanks Again. -Ed

      CODE:

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="initApp()" layout="absolute" xmlns="*">

      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;
      import mx.rpc.events.*;

      [Bindable]
      public var acTest:ArrayCollection;

      public var subTest:Array;

      private function initApp():void
      {
      srv.send();
      acTest = new ArrayCollection();
      }

      private function resultHandler(event:ResultEvent):void
      {
      subTest = event.result.root.perseus_PerformanceCreativeReview.source as Array;
      acTest.source = subTest;
      }

      ]]>
      </mx:Script>

      <mx:HTTPService id="srv" url="results.xml" useProxy="false" result="resultHandler(event)"/>

      <mx:Panel x="10" y="10" width="552" height="259" layout="absolute">

      <mx:ColumnChart id="colClicksCreateYTD" dataProvider="{acTest}" width="477" height="288">
      <mx:horizontalAxis>
      <mx:CategoryAxis dataProvider="{acTest}" categoryField="CREATIVEGROUP1"/>
      </mx:horizontalAxis>

      <mx:verticalAxis>
      <mx:LinearAxis minimum="0" maximum="200000"/>
      </mx:verticalAxis>

      <mx:series>
      <mx:ColumnSeries dataProvider="{acTest}" displayName="Series 1" yField="DELIMPS" xField="CREATIVEGROUP1"/>
      </mx:series>

      <mx:secondVerticalAxis>
      <mx:LinearAxis minimum="0" maximum="200000"/>
      </mx:secondVerticalAxis>

      <mx:secondVerticalAxisRenderer>
      <mx:AxisRenderer placement="left" tickPlacement="inside"/>
      </mx:secondVerticalAxisRenderer>

      <mx:secondSeries>
      <mx:LineSeries dataProvider="{acTest}" displayName="Series 2" yField="CTR" xField="CREATIVEGROUP1"/>
      </mx:secondSeries>

      </mx:ColumnChart>

      </mx:Panel>
      </mx:Application>