数组集合的对象

发布于 2024-10-03 15:28:32 字数 1377 浏览 4 评论 0原文

我有一个应用程序,它获取一些数据库信息并将其推入数据网格或图表中。

我遇到过这样的错误:拥有一行并尝试在数组中使用它,以便我可以在我的应用程序中使用它。我注意到这是人们面临的一个相当普遍的问题,但无论我如何尝试,我似乎都无法解决它。

我的动作脚本有一个函数,可以通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

滥情稳全场 2024-10-10 15:28:32
     
     if( event.result.results.record is ObjectProxy ){
       var obj:ObjectProxy = event.result.results.record as ObjectProxy;
       _BusSegBuildSummary = new ArrayCollection([obj.object]);
      }
     
     if( event.result.results.record is ObjectProxy ){
       var obj:ObjectProxy = event.result.results.record as ObjectProxy;
       _BusSegBuildSummary = new ArrayCollection([obj.object]);
      }
你对谁都笑 2024-10-10 15:28:32

这尚未经过测试,但我认为它可能有效。只需使用 ArrayUtil.toArray() 将 ObjectProxy 转换为 ArrayCollection。

// import array utils
import mx.utils.ArrayUtil;

// later on
var record:* = event.result.results.record;
if (record is ArrayCollection) {
  _BusSegBuildSummary = record;
} else if (record is ObjectProxy) {
  _BusSegBuildSummary = new ArrayCollection(ArrayUtil.toArray(record)); 
}

This is untested but I think it might work. Just use ArrayUtil.toArray() to convert the ObjectProxy to an ArrayCollection.

// import array utils
import mx.utils.ArrayUtil;

// later on
var record:* = event.result.results.record;
if (record is ArrayCollection) {
  _BusSegBuildSummary = record;
} else if (record is ObjectProxy) {
  _BusSegBuildSummary = new ArrayCollection(ArrayUtil.toArray(record)); 
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文