Yes, I tried that and it is the correct node.

--- In flexcoders@yahoogroups.com, "Tracy Spratt" <tspr...@...> wrote:
>
> trace(x.toXMLString());  //is that the node you expect?
> 
>  
> 
> Tracy Spratt 
> Lariat Services 
> 
> Flex development bandwidth available 
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
> Behalf Of flexcoder2008
> Sent: Thursday, February 19, 2009 4:15 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> won't remove
> 
>  
> 
> What is the best way to do this? I tried this line and it returned
> true so it should be a good reference right?
> 
> var x:XML = unApprovedList[index];
> trace(x == unApprovedList[index]);
> 
> --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> , "Tracy Spratt" <tspratt@> wrote:
> >
> > Did you verify that var x:XML = unApprovedList[index]; is returning a
> > good reference?
> > 
> > 
> > 
> > Tracy Spratt 
> > Lariat Services 
> > 
> > Flex development bandwidth available 
> > 
> > ________________________________
> > 
> > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of flexcoder2008
> > Sent: Thursday, February 19, 2009 3:57 PM
> > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> > Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> > won't remove
> > 
> > 
> > 
> > Thanks Tracey - yes I am doing that as well.
> > 
> > I'm trying a new approach now - the problem now is that when I try to
> > retrieve the item index, even though I can see that the object is
> > there, I am getting an index of -1. Is there something wrong with
> > this code block?
> > 
> > approvedList.addItem(myObject.copy());
> > 
> > var index:int = 0;
> > for each(var o:Object in unApprovedList){
> > if(o.id == o.id.toString()){
> > break;
> > }
> > else
> > index++; 
> > 
> > }
> > 
> > var x:XML = unApprovedList[index];
> > // x should refer to the same object in unApprovedList!
> > 
> > var index:int = unApprovedList.getItemIndex(x); // is returning -1
> > unApprovedList.removeItemAt(index);
> > 
> > --- In flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > , "Tracy Spratt" <tspratt@> wrote:
> > >
> > > Good.
> > > 
> > > 
> > > 
> > > Are you using copy() when you addItem() to the approvedList?
> > > 
> > > 
> > > 
> > > Tracy Spratt 
> > > Lariat Services 
> > > 
> > > Flex development bandwidth available 
> > > 
> > > ________________________________
> > > 
> > > From: flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > [mailto:flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > ] On
> > > Behalf Of flexcoder2008
> > > Sent: Thursday, February 19, 2009 2:49 PM
> > > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com> 
> > > Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items
> > > won't remove
> > > 
> > > 
> > > 
> > > The collections are independent. 
> > > When my app starts up I have an XML variable that gets split into 2
> > > seperate lists.
> > > 
> > > So for example:
> > > 
> > > var myList:XML
> > > 
> > > I then split the lists into 2 like so:
> > > 
> > > for each(var x:XML in myList){
> > > if(x.Status == "UnApproved") 
> > > unApproved.addItem(x.copy()); 
> > > else if(x.Status == "Approved") 
> > > approvedList.addItem(x.copy()); 
> > > }
> > > 
> > > I used the .copy() method to ensure that this isn't tied back to the
> > > original XML by reference.
> > > 
> > > --- In flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com>
> > > , "Tracy Spratt" <tspratt@> wrote:
> > > >
> > > > First, are you sure your collections are independent? If you use
> the
> > > > same XMLList for both, they are not.
> > > > 
> > > > 
> > > > 
> > > > Tracy Spratt 
> > > > Lariat Services 
> > > > 
> > > > Flex development bandwidth available 
> > > > 
> > > > ________________________________
> > > > 
> > > > From: flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com>
> > > [mailto:flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com>
> > > ] On
> > > > Behalf Of flexcoder2008
> > > > Sent: Thursday, February 19, 2009 2:27 PM
> > > > To: flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com> 
> > > > Subject: [flexcoders] Re: Weird XMLListCollection behaviour -
> items
> > > > won't remove
> > > > 
> > > > 
> > > > 
> > > > I should make a correction...the 2nd example doesn't work....where
> I
> > > > am using the delete with an index. That just removes one of the
> > nodes
> > > > of the object itself.
> > > > 
> > > > So I am still stuck as to how to successfully remove a shared
> object
> > > > between 1 list and another and have the item removed from 1
> datagrid
> > > > and added to another.
> > > > 
> > > > --- In flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com> 
> > > <mailto:flexcoders%40yahoogroups.com>
> > > <mailto:flexcoders%40yahoogroups.com>
> > > > , "flexcoder2008" <djohnson29@> wrote:
> > > > >
> > > > > I am having all sorts of problems with removing items from an
> > > > > XMLListCollection. Not sure if this is because the dataBinding
> is
> > > > > preventing the items from being removed or not - I'm hoping
> > someone
> > > > > who has run into this issue as well can give me some insight.
> > > > > 
> > > > > I have 2 XMLListCollections, each 1 is bound to a seperate
> > DataGrid.
> > > > > 
> > > > > There is an approvedItemList bound to dgApproved, and an
> > > > > unApprovedList bound to dgUnApproved.
> > > > > 
> > > > > Sometimes, I want to remove an object from the 1 list, and then
> > add
> > > it
> > > > > to the other list. (I am using Cairngorm by the way)
> > > > > 
> > > > > For example, I want to take an item in the unApprovedList and
> add
> > it
> > > > > to the ApprovedList. So first I would add the object to the
> > > > > ApprovedList, and then get the Index of the object in the
> > > > > UnApprovedList and use RemoveAt like so:
> > > > > 
> > > > > approvedList.addItem(myObject);
> > > > > var index:int = unApprovedItemList.getItemIndex(myObject);
> > > > > unApprovedList.removeAt(index);
> > > > > 
> > > > > I am looking at the collections in the watch window, and I can
> see
> > > > > that when the .removeAt fires, the object is still left in the
> > > > > unApprovedList! Why is this happening?
> > > > > 
> > > > > I then attempted to remove the item this way as a workaround:
> > > > > 
> > > > > approvedList.addItem(myObject);
> > > > > 
> > > > > var index:int = 0;
> > > > > for each(var o:Object in unApprovedList){
> > > > > if(o.Id == myObject.Id.toString()){
> > > > > delete o[index];
> > > > > break;
> > > > > }
> > > > > else
> > > > > index++; 
> > > > > 
> > > > > }
> > > > > 
> > > > > Here again, when the delete command gets hit, the line executes,
> > but
> > > > > the object is left in the collection. I am left with 2 copies,
> the
> > > > > newly added one in the approvedList, and the leftover copy that
> > I've
> > > > > tried to delete in the unApprovedList.
> > > > > 
> > > > > Is the databinding somehow making a copy or "locking" that
> object?
> > > > >
> > > >
> > >
> >
>


Reply via email to