you can do a for each to do this
var itemToRemove:int = 2;
var newArray:ArrayCollection = new ArrayCollection();
for each(var a:Object in gridData) {
if(a.grid != gridToRemove){
newArrayCol.addItem(a);
}
}
gridData = newArray;
if you want to get the index of your item you can do something like this...
var index:int = 0;
for each(var a:Object in gridData) {
if(a.grid == gridToRemove){
index = gridData.indexOf(a);
}
}
2011/9/2 Onyx <[email protected]>
> Hi all
>
> I need some help with ArrayCollection. something so screamingly stupid but
> cant get my head around it. Its the first time im using ArrayCollection and
> cant get it to work properly. Would really appreciate some help
>
> ok so I have an ArrayCollection
>
> private var gridData:ArrayCollection = new ArrayCollection(); private
> function addTo():void { gridData.addItem({grid:"1",image:
> "src/images/a1.jpg",map:"2"}); }
>
> ok so far so good. Ive simplified the function just to get the idea across.
> now in another function I would like to remove a certain set of
> information. so lets say may ArrayCollection now looks as follows.
> item 1: grid:"1",image:"src/images/a1.jpg",map:"2"
> item 2: grid:"2",image:"src/images/a2.jpg",map:"9"
> item 3: grid:"3",image:"src/images/a3.jpg",map:"5"
>
> if I want to remove say item 2 and all I have to find it in the
> ArrayCollection is the grid number in this case grid:2
>
> private function removeFrom():void {
> gridData.removeItemAt({grid:2});
> // I know how to do this by index but because items are added in random
> order I wont always know what the index is.
>
> }
> how would I do this please please help. Im thinking these items should be
> in an object and then added to the ArrayCollection but then what is the
> point of defining pockets grid,image,map?
>
> thank you all in advance
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps API For Flash" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-maps-api-for-flash/-/KG1XHa_abcYJ.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-maps-api-for-flash?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Google Maps API For Flash" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api-for-flash?hl=en.