PDA

View Full Version : Can not get data from actionscript db operation class?


sandwish
03-19-2007, 03:43 PM
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!

hangalot
03-20-2007, 09:38 AM
i think the sound of that is a cast failing silently.

sandwish
03-21-2007, 01:59 AM
Is there anything that I can do to fix it?

Thank you:rolleyes:

hangalot
03-21-2007, 06:48 AM
have you tried using the debugger. convert the data into a proper dataprovider ?

sandwish
03-24-2007, 05:18 PM
Thanks for your answer.
But how to convert it to dataprovider?

I can not find it from flexdoc...

In my opinion, the problem is that the data assignment happened before the database data came from the netconnection.

But how to change it...

Thx!

sandwish
04-01-2007, 02:42 AM
I have met the similar problem before?:eek: