3 Replies Latest reply on Jul 30, 2007 9:31 AM by ADSIntern

    RemoteObject Custom Component


      I'm currently working on a Flex project that displays data from an Oracle database via a RemoteObject/CFC. I'm trying to make the RemoteObject its own custom component and am running into some issues with instantiations of the RemoteObject component in other component files, and a resultant loss of data due to scoping.

      This is the problem in detail:
      1) A Panel component which holds a PieChart instantiates a RemoteObject component, and calls one of its methods.

      2) The RemoteObject invokes the appropriate method, qureies the database, and feeds the results back to a function in the script block.

      3) The function in the script block assigns the results to an ArrayCOllection instantiated as a Bindable variable at the top of the script block

      4) The PieChart object in the Panel component references the publically declared ArrayCollection in the RemoteObject and assigns it as a dataProvider.

      This is where I run into problems. The ArrayCollection local to the RemoteObject has data in it at while still in the results function, but loses all of the data upon leaving that function's scope (despite the ArrayCollection being declared outside the scope of the function).

      My code for the RemoteObject COmponent is below, followed by the code for my Panel/PieChart component. I would really appreciate any help or feedbalc that someone might have to offer!

      Here's the code from the RemoteObject Component:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml"
      import mx.utils.ArrayUtil;
      import com.adobe.windowedApplication.managers.WindowManager;
      import mx.core.UIComponent;
      import mx.collections.ArrayCollection;
      import mx.utils.ObjectUtil;
      import mx.controls.Alert;
      import mx.rpc.events.FaultEvent;
      import mx.rpc.events.ResultEvent;

      //here is the publically declared ArrayCollection outside the scope of the function
      public var dp_pwPieData:ArrayCollection;

      public function dp_pwPie_result(event:ResultEvent):void
      var temp:ArrayCollection = event.result as ArrayCollection;
      dp_pwPieData = new ArrayCollection(temp.toArray());
      //data is in the ArrayCollection at this point

      public function traceStuff():void
      //this function is valled after the value for dp_pwPieData,
      //but it contains nothing
      private function server_fault(event:FaultEvent):void
      // dump error message
      Alert.show( ObjectUtil.toString(event.fault) );
      <mx:RemoteObject id="dataManager"
      <mx:method name="dp_pwPie"


      Here is the code from the script block of the Panel/PieChart component:

      import mx.collections.ArrayCollection;
      import Components.*;

      private var _key:Object;

      public var ro:ROComponent = new ROComponent();

      public function get key():Object
      return this._key;
      public function set key(key:Object):void
      this._key = key;

      //called on creationComplete for the Panel/PieChart component
      private function refreshList(event:Event):void
      this.pwPieChart = new PieChart();
      this.pwPieSeries = new PieSeries();


      //nothing in the ArrayCollection
      this.pwPieChart.dataProvider = this.ro.dp_pwPieData;