数组集合的对象
我有一个应用程序,它获取一些数据库信息并将其推入数据网格或图表中。
我遇到过这样的错误:拥有一行并尝试在数组中使用它,以便我可以在我的应用程序中使用它。我注意到这是人们面临的一个相当普遍的问题,但无论我如何尝试,我似乎都无法解决它。
我的动作脚本有一个函数,可以通过 ASP 快速访问数据库,并返回事件中的数据 - 如下(显然我已经删除了一些内容 - 对 mssqlQuery 函数进行了大量调用 - 只有我有创伤的一个)如下)
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;
所以 - 如果结果中有多个记录 - 那么我们就很好 - 它是跟踪(“这是对象代理”);有点麻烦。 我认为我必须将对象转换为数组集合,并且我尝试了多种不同的方法但没有成功。
有什么想法吗?我已经挣扎了一段时间了,我很恐慌!
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 function 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 panicking!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这尚未经过测试,但我认为它可能有效。只需使用 ArrayUtil.toArray() 将 ObjectProxy 转换为 ArrayCollection。
This is untested but I think it might work. Just use ArrayUtil.toArray() to convert the ObjectProxy to an ArrayCollection.