Yep!
 
The post you just replied to a few minutes ago, just clarified that.  Up until then, I was not aware of that.
 
Thanks again for the info -
 
Mike


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Mike Nimer
Sent: Friday, July 28, 2006 10:18 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] How does Flex 2.0 handle ColdFusion Query results?

Your not doing the same thing
 
this is casting the object
> categories = event.result as ArrayCollection;

 

this is creating new objects

>categories = new ArrayCollection( event.result as Array);
    -or-
    categories = new ArrayCollection( event.result)

 

Now why doesn't it work? The event.result variable is already an ArrayCollection. And if you look at the asdoc for the ArrayCollection constuctor, it takes an Array (An ArrayCollection object is NOT an Array ).

 

And when you do this "new ArrayCollection(event.result) " Your actually doing "new ArrayCollection( SomeArrayCollectionVariable )" And the ArrayCollection constructor doesn't support creating a new ArrayCollection from an existing ArrayCollection.

 

 

 

So things that would work:

Casting

categories = event.result as ArrayCollection;

categories = ArrayCollection(event.result); // notice the lack of the "new" keyword.

 

Create new

categories = new ArrayCollection( (event.result as ArrayCollection).souce ); // the .source property of the ArrayCollection is a proper Array.

 

 

hope that made sense,

---nimer

 

 


----- Original Message ----
From: Mike Anderson <[EMAIL PROTECTED]>
To: flexcoders@yahoogroups.com
Sent: Thursday, July 27, 2006 5:10:25 PM
Subject: RE: [flexcoders] How does Flex 2.0 handle ColdFusion Query results?

Hello Dave and All,
 
I checked out the Article and it worked!!
 
But I am confused why it worked...  In some respects, I thought I was doing the same thing - but just in a different way.  I was wondering if you could explain why one piece of code works, and the code I originally used did NOT work.  For the example code below, you can all assume that I already declared a public variable called 'categories' , and cast it as an ArrayCollection. ..
 
For starters, here is the code that works from the Article:
 
    categories = event.result as ArrayCollection;
 
And for the code that does NOT work:
 
    categories = new ArrayCollection( event.result as Array);
    -or-
    categories = new ArrayCollection( event.result) ;
 
If I understand your post correctly, you are saying that the "Event Object" performs some type of "smart conversions" - only when it's being directly assigned to a variable?  And if that's true, this conversion never gets triggered, when it's placed inside of a Constructor (for example an ArrayCollection) ?  This would explain why my code did not work.
 
I don't know - just thinking out loud here.  I would love to know more about how this all works, especially since there were so MANY massive changes from Flex 1.0 Beta, all the way to the latest release version (not to mention Flash Remoting, which the earliest versions of Flex had a lot of similarities to).  I am sure learning how this all works, will save me a LOT of headaches down the road - especially since I ONLY write Data-Driven applications (RIA's) which all make massive amounts of database calls.
 
Thanks for all your wonderful advice!
 
Mike
 


From: [EMAIL PROTECTED] ups.com [mailto:flexcoders@ yahoogroups. com] On Behalf Of Dave Carabetta
Sent: Thursday, July 27, 2006 1:04 PM
To: [EMAIL PROTECTED] ups.com
Subject: Re: [flexcoders] How does Flex 2.0 handle ColdFusion Query results?

On 7/27/06, Mike Anderson <[EMAIL PROTECTED] net> wrote:
Hello Shannon :)
 
Yes, I am doing precisely that.  I was trying to avoid posting code, but it's the easiest way to show you everything I am trying to do.  You can assume too, that yes I am bringing back a valid RecordSet from ColdFusion, and the FieldNames match up exactly with what was brought back.  Since the data is all there, Flex for some reason, is not iterating through all the data and parsing it out properly.  I just have a hard time with this - since this works fine with my Flash Remoting app, and that I am bringing back a native Query Object from ColdFusion.  I must be missing something, or am not properly casting something.  As far as I can tell, I am properly coding the Grid Columns - but maybe I am not...  One last thing - I am running something similar to Flash's NetConnection Debugger - and I am for sure getting back a valid response from the CF Server - an Array of Objects, all properly formatted and casted.
 
If you could shed further light, as to why no data shows up in my DataGrid when the app runs, I'd be very grateful :)

Mike,

A bit has changed between 1.5 and 2.0 with regard to Flex, and for the better (aka easier). To that end, yesterday I blogged a post on using Arrays vs. ArrayCollections in Flex and, at the bottom, there is a semi-complete MXML application that shows calling an HTTPService and handling the results for display in the DataGrid. In short, the new ResultEvent class should make its way into your code, as that class is the one that has the "smarts" to handle ColdFusion queries and cast it to an appropriate local data structure. Watch for link wrapping:

http://www.cbetta. com/blog/ index.cfm/ 2006/7/26/ array-vs- array-collection -in-flex- 2-with-a- coldfusion- slant

Hope this helps.

Regards,
Dave.

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to