Correction:
"The issue is that there is only one "lastResult" for a given RPC Object
instance."
I typically use a single instance for all calls, but not everyone does.
Tracu

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Tracy Spratt
Sent: Thursday, November 13, 2008 6:21 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] ArrayCollection

The issue is that there is only one "lastResult" for the entire
framework.
 
"There is only one result" No, this is not correct. Because they are
asynchronous, there can be multiple pending RPC data calls.  There is no
assurance that the first RPC call is the first returned.
 
Between the time the result returns, lastResult is set, the result event
is dispatched, calling your handler, and your handler gets to the line
that uses lastResult, it is very possible that another result has
returned, overwriting the value in lastResult.  Typically it is actually
set to null by the framework, rather than sneaking in some other data,
but that is just as dangerous.  This was a real issue in a thread six or
eight months ago.
 
If you only call a single RPC at a time, there will be no problem, but
complex apps often have many outstanding calls an a given moment.
 
Why take any risk?  Is there some reason you *like* lastResult over
using the event.result object?  
 
Tracy
 

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Mike Duncan
Sent: Thursday, November 13, 2008 4:25 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] ArrayCollection
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I am not quite sure by what you mean "...are not garrunteed that it will
have the value in the result you expect." There is only one result. And,
by "dangerous", are you talking about a memory leak or something?

If there is a case when I get no results, then I can understand this
logic, but in my case, there is always at least one result. A single
child within the root element of the returned XML that is.

I appreciate the heads up though.

Mike Duncan
ISSO, Application Security Specialist
Government Contractor with STG, Inc.
NOAA :: National Climatic Data Center
151 Patton Ave.
Asheville, NC 28801-5001
[EMAIL PROTECTED] <mailto:mike.duncan%40noaa.gov> 
828.271.4289

Tracy Spratt wrote:
> 
> 
> Mike,
> 
> It is dangerous to use lastResult in this manner:
> 
> scans = new ArrayCollection([getScan.lastResult.vector.scan]);
> 
> You are not garrunteed that it will have the value in the result you
expect.
> 
> In most cases it will work ok but the correct way is:
> 
> scans = new ArrayCollection([event.result.vector.scan]);
> 
> 
> 
> lastResult is intended only for use in binding expressions.
> 
> 
> 
> Tracy
> 
> 
> 
> ----------------------------------------------------------
> 
> *From:* flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
]
> *On Behalf Of *Mike Duncan
> *Sent:* Thursday, November 13, 2008 3:06 PM
> *To:* flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>

> *Subject:* Re: [flexcoders] ArrayCollection
> 
> 
> 
> This is how I got around this...
> 
> -------------
> import mx.uils.ObjectProxy;
> import mx.collections.ArrayCollection;
> 
> [Bindable] private scans:ArrayCollection;
> 
> private function handleGetScansResults(event:ResultEvent):void {
> //Note: getScan is a HTTPService object.
> if(getScan.lastResult.vector.scan is ObjectProxy) {
> scans = new ArrayCollection([getScan.lastResult.vector.scan]);
> }else{
> scans = getScan.lastResult.vector.scan as ArrayCollection;
> }
> }
> -------------
> (sorry for any word wrapping)
> 
> Dunno if someone else already suggested this, but I hope this helps.
> 
> Mike Duncan
> ISSO, Application Security Specialist
> Government Contractor with STG, Inc.
> NOAA :: National Climatic Data Center
> 151 Patton Ave.
> Asheville, NC 28801-5001
> [EMAIL PROTECTED] <mailto:mike.duncan%40noaa.gov>
<mailto:mike.duncan%40noaa.gov>
> 828.271.4289
> 
> jch92592 wrote:
> 
> 
>> All,
> 
>> I am using an ArrayCollection that I populate with the results from a
>> ColdFusion RPC.
> 
>> All works well when there is more than 1 record. When only 1 record
is
>> returned, the data is not assigned to the ArrayCollection.
> 
>> Any suggestions?
> 
>> Thank you,
>> jh
> 
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD4DBQFJHJsonvIkv6fg9hYRAi3+AJd4NApCYammCT/86WCi5lPQvChcAJ47p7Zr
YEc4klxZno0I7Je3Se73gw==
=MSe4
-----END PGP SIGNATURE-----
 

Reply via email to