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.
Hey Mike. First and very much foremost I just want to be clear that I'm new to ActionScript 3 myself and that my tips/advice are based purely on personal experience (as opposed to in-depth knowledge of the underlying intricacies of the framework). To that end, Mike Nimer (ColdFusion engineer extraordinaire) posted the difference between the two in anoth thread. If you don't mind, I'll just quote him because I think that he's going to be better at explaining this than I'll be!
Regarding why using the "as" keyword works, Nimer notes:
"In ColdFusion all queries are returned as a true ArrayCollection objects, so you don't need to create your own. So with this syntax you are just casting, or telling the compiler, the variable that you already know the datatype of (ArrayCollection) is an real ArrayCollection."
Regarding why there are issues with using the ArrayCollection contructor:
"Here you are telling the compiler the result is an Array, so you need to *create* a new ArrayCollection object based on this array."
My interpretation of the difference between the two is that the "as" keyword approach just re-inforces the already existing ArrayCollection datatype that is returned by ColdFusion while the second approach is casting an ArrayCollection to an Array, which I guess the compiler doesn't like. In the third case you tried (categories = new ArrayCollection( event.result)), I wouldn't expect it to work because the ArrayCollection class expects an Array as its constructor argument and you were passing in an ArrayCollection.
Hope this helps?
Again, I'm learning much as you're learning, so if you have any further insights/questions, this is the best place to ask!
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
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
__,_._,___

