No, casting in AS takes the form of TypeToCastTo(objectToCast), and objectToCast as TypeToCastTo is virtually identical, except for the fact that a failed cast with as returns null, and the more traditional syntax will throw an exception upon failure.
new ArrayCollection(something) calls the constructor, whose only (optional) argument is the Array instance to use as the source for the collection. More explanation and discussion here: http://tech.groups.yahoo.com/group/flexcoders/message/61175 HTH, Ben --- In [email protected], Doug McCune <[EMAIL PROTECTED]> wrote: > > I believe: ArrayCollection(something) > will do the same thing as: new ArrayCollection(something) > and not the same thing as: something as ArrayCollection > > To cast to ArrayCollection you have to use "as" > > Doug > > Tracy Spratt wrote: > > > > Good question. I still stumble over casts vs new vs top-level > > functions. I bet that will work. > > > > Tracy > > > > > > > > ------------------------------------------------------------------------ > > > > *From:* [email protected] [mailto:[EMAIL PROTECTED] > > *On Behalf Of *ben.clinkinbeard > > *Sent:* Wednesday, January 31, 2007 7:45 PM > > *To:* [email protected] > > *Subject:* [flexcoders] Re: fixed the problem!! > > > > > > > > Does myExperiments = > > ArrayCollection(event.result.experiments.experiment) work? > > > > --- In [email protected] > > <mailto:flexcoders%40yahoogroups.com>, "Tracy Spratt" <tspratt@> wrote: > > > > > > That IS unexpected. > > > > > > Tracy > > > > > > > > > > > > ________________________________ > > > > > > From: [email protected] > > <mailto:flexcoders%40yahoogroups.com> > > [mailto:[email protected] > > <mailto:flexcoders%40yahoogroups.com>] On > > > Behalf Of Cashorali, Tanya M. > > > Sent: Wednesday, January 31, 2007 1:27 PM > > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > > > Subject: [flexcoders] fixed the problem!! > > > > > > > > > > > > Well, who knew that myExperiments = event.result.experiments.experiment > > > as ArrayCollection would work > > > > > > > > > > > > But myExperiments = new > > > ArrayCollection(event.result.experiments.experiment) wouldn't? > > > > > > > > > > > > Lots of hours of aggravation, but Flex is so pretty it's almost worth > > > it. > > > > > > > > > > > > ________________________________ > > > > > > From: [email protected] > > <mailto:flexcoders%40yahoogroups.com> > > [mailto:[email protected] > > <mailto:flexcoders%40yahoogroups.com>] On > > > Behalf Of Cashorali, Tanya M. > > > Sent: Wednesday, January 31, 2007 12:46 PM > > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > > > Subject: RE: [flexcoders] Binding HTTPService xml to ArrayCollection for > > > Datagrid > > > > > > > > > > > > Ok after a lot of painful debugging.. I've found something strange. > > > > > > > > > > > > Instead of an ArrayCollection, I declared myExperiments as an Object. > > > > > > The XML format is like this: > > > > > > <experiments> > > > > > > <experiment> > > > > > > <title></title> > > > > > > <machine></machine> > > > > > > <username></username> > > > > > > </experiment> > > > > > > <experiment> > > > > > > <title></title> > > > > > > <machine></machine> > > > > > > <username></username> > > > > > > </experiment> > > > > > > </experiments> > > > > > > > > > > > > private function resultHandler(event:ResultEvent):void > > > > > > { > > > > > > myExperiments = event.result.experiments.experiment; > > > > > > } > > > > > > > > > > > > Then I set my dataprovider in my datagrid = myExperiments and for some > > > reason this works to display the experiments. > > > > > > Why doesn't an ArrayCollection work? > > > > > > > > > > > > Sorry for all the emails but this has been a problem for too long and > > > seems like it should be simple. > > > > > > > > > > > > ________________________________ > > > > > > From: [email protected] > > <mailto:flexcoders%40yahoogroups.com> > > [mailto:[email protected] > > <mailto:flexcoders%40yahoogroups.com>] On > > > Behalf Of Cashorali, Tanya M. > > > Sent: Wednesday, January 31, 2007 12:36 PM > > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > > > Subject: RE: [flexcoders] Binding HTTPService xml to ArrayCollection for > > > Datagrid > > > > > > > > > > > > Please I just need to know how to bind the results of an HTTPService > > > request (which generates XML) to an ArrayCollection!!! > > > > > > > > > I don't think it should be this difficult!?! > > > > > > > > > > > > ________________________________ > > > > > > From: [email protected] > > <mailto:flexcoders%40yahoogroups.com> > > [mailto:[email protected] > > <mailto:flexcoders%40yahoogroups.com>] On > > > Behalf Of Cashorali, Tanya M. > > > Sent: Wednesday, January 31, 2007 11:16 AM > > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > > > Subject: RE: [flexcoders] Binding HTTPService xml to ArrayCollection for > > > Datagrid > > > > > > > > > > > > Still no luck.. I'm trying to check the length of the array and an > > > Alert.show() won't even display anything. Could it be order in which > > > I'm executing everything? > > > > > > For instance, I can't call the display_experiments.php script until > > > after a user has logged in so it can query the database for his > > > experiments. > > > > > > I have a checkLogin function that sends the display_experiments > > > HTTPService call after the user has logged in. > > > > > > > > > > > > What could I be doing wrong? > > > > > > > > > > > > -Tanya > > > > > > > > > > > > ________________________________ > > > > > > From: [email protected] > > <mailto:flexcoders%40yahoogroups.com> > > [mailto:[email protected] > > <mailto:flexcoders%40yahoogroups.com>] On > > > Behalf Of Brian Holmes > > > Sent: Wednesday, January 31, 2007 10:41 AM > > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > > > Subject: RE: [flexcoders] Binding HTTPService xml to ArrayCollection for > > > Datagrid > > > > > > > > > > > > on return use > > > > > > > > > > > > myExperiments = new > > > ArrayCollection(event.result.experiments.experiment); > > > > > > > > > > > > > > > > > > if expirement is the repeating element, then you need to use > > > (event.result.expirements) > > > > > > > > > > > > > > > > > > > > > > > > b. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ________________________________ > > > > > > From: [email protected] > > <mailto:flexcoders%40yahoogroups.com> > > [mailto:[email protected] > > <mailto:flexcoders%40yahoogroups.com>] On > > > Behalf Of Cashorali, Tanya M. > > > Sent: Wednesday, January 31, 2007 8:32 AM > > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > > > Subject: RE: [flexcoders] Binding HTTPService xml to ArrayCollection for > > > Datagrid > > > > > > The problem is related to the format of the XML I think. Here's a > > > portion of my php script (SQL statement not included). > > > > > > > > > > > > $output = "<experiments>"; > > > > > > while (OCIFetchInto($result, $row, OCI_ASSOC)) > > > > > > { > > > > > > $output .= > > > "<experiment><title>".$row['TITLE']."</title><machine>".$row['MACHINE']. > > > "</machine><username>".$row['USERNAME']."</username><details>".$row['DET > > > AILS']."</details><month>".$row['EMONTH']."</month><day>".$row['EDAY']." > > > </day><year>".$row['EYEAR']."</year></experiment>"; > > > > > > } > > > > > > $output .= "</experiments>"; > > > > > > > > > > > > This works fine when using > > > display_experiments.lastResult.experiments.experiment.. but it does not > > > work when binding using a resultHandler as > > > > > > > > > > > > [Bindable] > > > > > > private var myExperiments:ArrayCollection; > > > > > > > > > > > > private function resultHandler(event:ResultEvent):void > > > > > > { > > > > > > myExperiments=event.result.experiments.experiment; > > > > > > } > > > > > > > > > > > > And here's my HTTPService call: > > > > > > <mx:HTTPService id="display_experiments" result = "resultHandler(event)" > > > url="http://localhost:8080/displayExperiments.php > > <http://localhost:8080/displayExperiments.php>" useProxy="false" > > > method="POST"> > > > > > > <mx:request xmlns=""> > > > > > > <username>{username.text}</username> > > > > > > </mx:request> > > > > > > </mx:HTTPService> > > > > > > > > > > > > Trying to populate the datagrid with {myExperiments} doesn't work. > > > > > > Do I need to output the XML in some other way? > > > > > > > > > > > > Thanks, > > > > > > Tanya > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ________________________________ > > > > > > From: [email protected] > > <mailto:flexcoders%40yahoogroups.com> > > [mailto:[email protected] > > <mailto:flexcoders%40yahoogroups.com>] On > > > Behalf Of Cashorali, Tanya M. > > > Sent: Tuesday, January 30, 2007 4:58 PM > > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > > > Subject: RE: [flexcoders] Binding HTTPService xml to ArrayCollection for > > > Datagrid > > > > > > > > > > > > The datagrid doesn't even get populated and I'm making sure I actually > > > send the httpservice request on creationComplete of the datagrid itself. > > > > > > I can drag ok when I use pseudo data that is not populated from the > > > HTTPService. I need the HTTPService to execute the php script which > > > pulls the data off the backend. > > > > > > > > > > > > ________________________________ > > > > > > From: [email protected] > > <mailto:flexcoders%40yahoogroups.com> > > [mailto:[email protected] > > <mailto:flexcoders%40yahoogroups.com>] On > > > Behalf Of Tracy Spratt > > > Sent: Tuesday, January 30, 2007 4:44 PM > > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > > > Subject: RE: [flexcoders] Binding HTTPService xml to ArrayCollection for > > > Datagrid > > > > > > > > > > > > Whare are you stuck? > > > > > > > > > > > > Can you populate the source datagrid ok? > > > > > > > > > > > > Can you drag from the soruce to the target ok? > > > > > > > > > > > > Do you need the HTTPService for updating the back-end, of for getting > > > data into flex? > > > > > > > > > > > > Tracy > > > > > > > > > > > > ________________________________ > > > > > > From: [email protected] > > <mailto:flexcoders%40yahoogroups.com> > > [mailto:[email protected] > > <mailto:flexcoders%40yahoogroups.com>] On > > > Behalf Of Cashorali, Tanya M. > > > Sent: Tuesday, January 30, 2007 4:00 PM > > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > > > Subject: [flexcoders] Binding HTTPService xml to ArrayCollection for > > > Datagrid > > > > > > > > > > > > I have followed the example exactly as Adobe's book shows in Lesson 12 > > > (Dragging and Dropping Between Two Datagrids) with no luck. > > > > > > > > > > > > I need to be able to bind the results of an HTTPService call (which > > > executes a php script and returns rows in XML format), to an > > > ArrayCollection or whatever datatype can populate a datagrid. > > > > > > Everytime I drag and drop between two datagrids I need to change this > > > ArrayCollection. > > > > > > > > > > > > Any help willl be greaaaatly appreciated please!!! Also, is it better > > > practice to keep updating the database with every drag and drop, or to > > > manipulate the ArrayCollection clientside, and when all's said and done > > > finally update the database with one call? > > > > > > > > > > > > Thank you > > > > > > THE INFORMATION TRANSMITTED IN THIS ELECTRONIC COMMUNICATION IS INTENDED > > > ONLY FOR THE PERSON OR ENTITY TO WHOM IT IS ADDRESSED AND MAY CONTAIN > > > CONFIDENTIAL AND/OR PRIVILEGED MATERIAL. ANY REVIEW, RETRANSMISSION, > > > DISSEMINATION OR OTHER USE OF OR TAKING OF ANY ACTION IN RELIANCE UPON, > > > THIS INFORMATION BY PERSONS OR ENTITIES OTHER THAN THE INTENDED > > > RECIPIENT IS PROHIBITED. IF YOU RECEIVED THIS INFORMATION IN ERROR, > > > PLEASE CONTACT THE SENDER AND THE PRIVACY OFFICER, AND PROPERLY DISPOSE > > > OF THIS INFORMATION. > > > > > > THE INFORMATION TRANSMITTED IN THIS ELECTRONIC COMMUNICATION IS INTENDED > > > ONLY FOR THE PERSON OR ENTITY TO WHOM IT IS ADDRESSED AND MAY CONTAIN > > > CONFIDENTIAL AND/OR PRIVILEGED MATERIAL. ANY REVIEW, RETRANSMISSION, > > > DISSEMINATION OR OTHER USE OF OR TAKING OF ANY ACTION IN RELIANCE UPON, > > > THIS INFORMATION BY PERSONS OR ENTITIES OTHER THAN THE INTENDED > > > RECIPIENT IS PROHIBITED. IF YOU RECEIVED THIS INFORMATION IN ERROR, > > > PLEASE CONTACT THE SENDER AND THE PRIVACY OFFICER, AND PROPERLY DISPOSE > > > OF THIS INFORMATION. > > > > > > THE INFORMATION TRANSMITTED IN THIS ELECTRONIC COMMUNICATION IS INTENDED > > > ONLY FOR THE PERSON OR ENTITY TO WHOM IT IS ADDRESSED AND MAY CONTAIN > > > CONFIDENTIAL AND/OR PRIVILEGED MATERIAL. ANY REVIEW, RETRANSMISSION, > > > DISSEMINATION OR OTHER USE OF OR TAKING OF ANY ACTION IN RELIANCE UPON, > > > THIS INFORMATION BY PERSONS OR ENTITIES OTHER THAN THE INTENDED > > > RECIPIENT IS PROHIBITED. IF YOU RECEIVED THIS INFORMATION IN ERROR, > > > PLEASE CONTACT THE SENDER AND THE PRIVACY OFFICER, AND PROPERLY DISPOSE > > > OF THIS INFORMATION. > > > > > > ________________________________ > > > > > > *** > > > The information in this e-mail is confidential and intended solely for > > > the individual or entity to whom it is addressed. If you have received > > > this e-mail in error please notify the sender by return e-mail delete > > > this e-mail and refrain from any disclosure or action based on the > > > information. > > > *** > > > > > > THE INFORMATION TRANSMITTED IN THIS ELECTRONIC COMMUNICATION IS INTENDED > > > ONLY FOR THE PERSON OR ENTITY TO WHOM IT IS ADDRESSED AND MAY CONTAIN > > > CONFIDENTIAL AND/OR PRIVILEGED MATERIAL. ANY REVIEW, RETRANSMISSION, > > > DISSEMINATION OR OTHER USE OF OR TAKING OF ANY ACTION IN RELIANCE UPON, > > > THIS INFORMATION BY PERSONS OR ENTITIES OTHER THAN THE INTENDED > > > RECIPIENT IS PROHIBITED. IF YOU RECEIVED THIS INFORMATION IN ERROR, > > > PLEASE CONTACT THE SENDER AND THE PRIVACY OFFICER, AND PROPERLY DISPOSE > > > OF THIS INFORMATION. > > > > > > THE INFORMATION TRANSMITTED IN THIS ELECTRONIC COMMUNICATION IS INTENDED > > > ONLY FOR THE PERSON OR ENTITY TO WHOM IT IS ADDRESSED AND MAY CONTAIN > > > CONFIDENTIAL AND/OR PRIVILEGED MATERIAL. ANY REVIEW, RETRANSMISSION, > > > DISSEMINATION OR OTHER USE OF OR TAKING OF ANY ACTION IN RELIANCE UPON, > > > THIS INFORMATION BY PERSONS OR ENTITIES OTHER THAN THE INTENDED > > > RECIPIENT IS PROHIBITED. IF YOU RECEIVED THIS INFORMATION IN ERROR, > > > PLEASE CONTACT THE SENDER AND THE PRIVACY OFFICER, AND PROPERLY DISPOSE > > > OF THIS INFORMATION. > > > > > > THE INFORMATION TRANSMITTED IN THIS ELECTRONIC COMMUNICATION IS INTENDED > > > ONLY FOR THE PERSON OR ENTITY TO WHOM IT IS ADDRESSED AND MAY CONTAIN > > > CONFIDENTIAL AND/OR PRIVILEGED MATERIAL. ANY REVIEW, RETRANSMISSION, > > > DISSEMINATION OR OTHER USE OF OR TAKING OF ANY ACTION IN RELIANCE UPON, > > > THIS INFORMATION BY PERSONS OR ENTITIES OTHER THAN THE INTENDED > > > RECIPIENT IS PROHIBITED. IF YOU RECEIVED THIS INFORMATION IN ERROR, > > > PLEASE CONTACT THE SENDER AND THE PRIVACY OFFICER, AND PROPERLY DISPOSE > > > OF THIS INFORMATION. > > > > > > THE INFORMATION TRANSMITTED IN THIS ELECTRONIC COMMUNICATION IS INTENDED > > > ONLY FOR THE PERSON OR ENTITY TO WHOM IT IS ADDRESSED AND MAY CONTAIN > > > CONFIDENTIAL AND/OR PRIVILEGED MATERIAL. ANY REVIEW, RETRANSMISSION, > > > DISSEMINATION OR OTHER USE OF OR TAKING OF ANY ACTION IN RELIANCE UPON, > > > THIS INFORMATION BY PERSONS OR ENTITIES OTHER THAN THE INTENDED > > > RECIPIENT IS PROHIBITED. IF YOU RECEIVED THIS INFORMATION IN ERROR, > > > PLEASE CONTACT THE SENDER AND THE PRIVACY OFFICER, AND PROPERLY DISPOSE > > > OF THIS INFORMATION. > > > > > > > >

