0 Replies Latest reply on Mar 24, 2007 10:09 AM by sandwish

    Can not get data from actionscript db operation class?

    sandwish
      DBOperation.as:
      import flash.events.*;
      import flash.net.NetConnection;
      import flash.net.ObjectEncoding;
      import flash.net.Responder;

      import mx.collections.ArrayCollection;
      import mx.controls.List;
      import mx.rpc.events.ResultEvent;
      import mx.collections.ArrayCollection;

      public class DBOperation
      {
      private var nc:NetConnection;
      private var responder:Responder;

      public var list:ArrayCollection;

      public function DBOperation():void{
      nc = new NetConnection();
      nc.objectEncoding = ObjectEncoding.AMF0;
      nc.connect("rtmp://localhost/ins");
      }


      public function getSolutionData(sql:String):Boolean
      {
      responder=new Responder(getSolutionList,null);
      nc.call
      ("dbo.getSolutionData",responder,sql);
      return true;
      }


      public function getSolutionList
      (solution:Object):void{
      var solutionList:Array = new Array();
      for(var items:String in solution)
      {
      solutionList.push
      ({label:items,title:solution[items].title,owner:solution
      [items].owner,submitTime:solution[items].submitTime,image:solution
      [items].image,imgInstruction:solution[items].imgInstruction});
      }
      list = new ArrayCollection(solutionList);

      }
      }
      ------------------------------------------------------------
      datagrid.mxml:

      <mx:Script>
      <![CDATA[
      import DBOperation;
      import mx.collections.ArrayCollection;

      [Bindable]
      private var solutionList:ArrayCollection;

      private function initDG():void{
      var dbo:DBOperation=new
      DBOperation();
      dbo.getSolutionData("some sql
      strings");

      solutionList=dbo.list;
      }
      ]]>
      </mx:Script>
      ------------------------------------------------------------
      my problem is I can get the data using DBOperation class,but I can not
      assign it to solutionList by "solutionList=dbo.list;"

      The debug information says dbo.list=null, however inside DBOperation
      the "list" is full of data.

      What's wrong with it??

      Thanks!