4 Replies Latest reply on Oct 12, 2008 6:23 AM by johny blaze

    RemoteObject and States

    D-D-Diderot
      Greeitngs,
      I have, what should be, a very simple need. I am using an mxml module basedf on a Panel. The basic jist is I have the state determined by a var passed, with a value of Pie or Bar, which I use a the default state. On creationComplete I execute the remote object and pass it to either the Pie chart state or the Bar chart state. I don't get any error's, it's just blank. Here is the code. I've poked around and made a lot of changes trying to debug it, so just ignore any wierdness. The pie chart is duped in the bar state just to make the bar chart wasn't causing the issue.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Panel xmlns:mx=" http://www.adobe.com/2006/mxml" x="1" y="0"
      layout="absolute" width="100%" height="100%"
      horizontalScrollPolicy="off" includeInLayout="true"
      visible="true" borderColor="#FFFFFF" borderThickness="0"
      borderThicknessBottom="0" borderThicknessLeft="0"
      borderThicknessRight="0" borderThicknessTop="0"
      dropShadowEnabled="false" verticalAlign="top"
      clipContent="true" headerHeight="1" useHandCursor="false" currentState="Pie" creationComplete="searchGetPointsAssigned.returnGroups_Points(AwardsDashboard_Variables); ">

      <mx:States>
      <mx:State name="Pie">
      <mx:AddChild>
      <!-- Render Pie Chart -->
      <mx:PieChart id="groupPieChart" height="100%" width="100%" enabled="true" useHandCursor="true" showAllDataTips="false" showDataTips="true" x="0" y="0">
      <mx:series>
      <mx:PieSeries nameField="GroupName" height="100%" width="100%" field="TotalPoints" labelPosition="insideWithCallout">
      <mx:showDataEffect>
      <mx:SeriesInterpolate minimumElementDuration="1000" duration="1000" />
      </mx:showDataEffect>
      </mx:PieSeries>
      </mx:series>
      </mx:PieChart>
      <mx:Legend id="chartLegend" dataProvider="{groupPieChart}" labelPlacement="right" includeInLayout="true"/>
      </mx:AddChild>
      </mx:State>
      <mx:State name="Bar">
      <mx:AddChild>
      <!-- Render Pie Chart -->
      <mx:PieChart id="groupPie2Chart" height="100%" width="100%" enabled="true" useHandCursor="true" selectionMode="none" showAllDataTips="false" showDataTips="true" x="0" y="0">
      <mx:series>
      <mx:PieSeries nameField="GroupName" height="100%" width="100%" field="TotalPoints" labelPosition="insideWithCallout">
      <mx:showDataEffect>
      <mx:SeriesInterpolate minimumElementDuration="1000" duration="1000" />
      </mx:showDataEffect>
      </mx:PieSeries>
      </mx:series>
      </mx:PieChart>
      </mx:AddChild>
      </mx:State>
      </mx:States>


      <mx:RemoteObject id="searchGetPointsAssigned" showBusyCursor="true" destination="ColdFusion" source="_assets_DashBoard.SearchEngine.searchIncludes.getPointsAssigned" endpoint=" http://www.xxx.com/flex2gateway/">
      <mx:method name="returnGroups_Points" result="processReportTypesHandler(event)" fault="mx.controls.Alert.show(event.fault.faultString)"/>
      </mx:RemoteObject>

      <mx:Script>
      <![CDATA[
      import assets.Variables.AwardsDashboard_Variables;
      import mx.rpc.events.ResultEvent;
      import mx.rpc.events.FaultEvent;
      import mx.utils.ObjectUtil;
      import mx.controls.Alert;
      import mx.collections.ArrayCollection;

      //pass returned data to the chart dataprovider
      private function processReportTypesHandler(returnedReportTypes:ResultEvent):void
      {
      if (AwardsDashboard_Variables.cbRenderMethod == "Pie"){
      groupPieChart.dataProvider = returnedReportTypes.result;
      }
      else if (AwardsDashboard_Variables.cbRenderMethod == "Pie"){
      groupPie2Chart.dataProvider = returnedReportTypes.result;
      }
      }
      ;]]>
      </mx:Script>

      </mx:Panel>


      I am assuming it is a fundemental issue with remoteobject and states and what is visible to flash when but, I am pretty new at this so what do I know. :)
      Thanks for any input or suggestions.
      -Kevin
        • 1. Re: RemoteObject and States
          riesvantwisk Level 1
          You might want to give databinding a shot.

          instead of this : groupPieChart.dataProvider = returnedReportTypes.result;

          You do something like this:

          myResult = returnedReportTypes.result;
          (MyResult is declared globally and Bindable)

          then in your pieChart you do something like this :


          <mx:PieChart dataprovider="{MyResult}" .... ... .... ... ..>

          Wild guess.....
          Ries
          • 2. Re: RemoteObject and States
            D-D-Diderot Level 1
            Thanks for the input but no go, it leaves me with the same issue. From my poking around and changing things up this is basically what happens: If I remove the states altogether, the remote obejct and chart works fine. If I remove the pie chart and just leave the date range in the state, it works fine. So, in a nutshell, it is only when I use states and add the pie chart does it not render anything, including the <mx:text> to show the date range...help?
            -Kevin
            • 3. Re: RemoteObject and States
              D-D-Diderot Level 1
              Hi Ries,
              Turns out you were correct. When I tried data binding the first time, I screwed it up. After much frustration, I went back to the binding issue and found my mistake so thanks very much, it is finally working.
              Kevin
              • 4. Re: RemoteObject and States
                johny blaze
                Hi I have been following up supplying the data to a pie chart, could you please post the solution you finally came up with?
                A lot of people like me would like to see the solution very urgently

                Thanks