11 Replies Latest reply on Nov 23, 2010 4:16 AM by TheGarfunkal

    Object to an ArrayCollection

    TheGarfunkal

      Hi

       

      I have an application that takes some database info and shoves it into a datagrid, or chart.

       

      I've come across this error of having a single row and trying to use it in an array so I can use it in my app.  Its come to my attention that its a pretty common problem that people face, but I don't seem to be able to get around it no matter what a try.

       

      My actionscript has a fucntion that trots of to the database via ASP, and returns the data in the event - as below (obv i've removed some stuff - load of calls are made to the mssqlQuery function - only the one I have trauma with is below)

       

       

       

      mssqlQuery("SELECT (CASE SLARag ,COUNT (SLARag)  as  Volume  FROM [CMI_ClientMI].[Portal].[BatchUpdate]","BusSegBuildSummary");}

       

      public static function  mssqlQuery(sql:String,fid:String):void {

      var http:HTTPService = new HTTPService;

      var parm:Object = new Object;

      parm.fas_sql = sql;

      parm.fas_db = mssql_db;

      http.url = mssql_url+"?irand="+Math.random();

      // http.showBusyCursor = true;

      http.request = sql;

      http.addEventListener(ResultEvent.RESULT, mssqlResult);

      http.addEventListener(FaultEvent.FAULT, mssqlFault);

      http.method = "POST";

      sqlToken = http.send(parm);

      sqlToken.param = fid;

      }

       

      //Var for BusSegBuildSummary arraycollection

      [Bindable]

      public static var _BusSegBuildSummary:ArrayCollection = new ArrayCollection();


        

      //Case statement for BusSegBuildSummary

      case "BusSegBuildSummary":

        


      if( event.result.results.record is ObjectProxy ){

      trace("this is object Proxy");


      }

      else{

         trace("this isnt object Proxy");

         _BusSegBuildSummary = event.result.results.record;

       

      }

       

      break;

       

       

      So - if the result has more than one record in it - then we are fine - its the trace("this is object Proxy"); bit that is troublesome.

      I think that I have to cast the object as an arraycollection and I've tried that a number of different ways with no success.

       

      Any ideas? I've been struggling for a while now and I'm panicing!