Adobe Dreamweaver Forums



Last 10 THreads :         Live stream player (Last Post : noobie_here - Replies : 0 - Views : 1 )           »          cfloop within a cfif tag (Last Post : Azadi - Replies : 2 - Views : 3 )           »          Making constraints on a symbol... (Last Post : sirkibble2 - Replies : 0 - Views : 1 )           »          Creating a boundry in the stage... (Last Post : fazstp - Replies : 2 - Views : 3 )           »          Director or Flash? (Last Post : Sean Wilson - Replies : 1 - Views : 2 )           »          DW8 Activation not working (Last Post : moonliner - Replies : 0 - Views : 1 )           »          Re: Mouse capture won't activate (Last Post : robertnagle - Replies : 0 - Views : 1 )           »          help! my FB3 has gone insane! (Last Post : peteandrus - Replies : 0 - Views : 1 )           »          help! my FB3 has gone insane! (Last Post : peteandrus - Replies : 0 - Views : 1 )           »          How come the html is being displayed, and not the link (Last Post : Skaterstu - Replies : 0 - Views : 1 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags: , ,



Reply
  #1 (permalink)  
Old 08-28-2008, 09:23 AM
nikos101
 
Posts: n/a
Diggs:
Default Is there a way to extract a subset of an arraycollection

Is there a way to extract a subset of an array collection where a particular
value is found, without doing it manually

EG {
{t=4,s=3}
{ t=3,s=3}
{ t=3,s=3}
}

Extract where t = 3

returns

{
{ t=3,s=3}
{ t=3,s=3}
}





Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-28-2008, 10:13 AM
anirudhs
 
Posts: n/a
Diggs:
Default Re: Is there a way to extract a subset of an arraycollection

Hi,

I don't think there is a non-manual way to do it. If it was the entire object, you could use .contains(obj)
Reply With Quote
  #3 (permalink)  
Old 08-28-2008, 02:45 PM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Is there a way to extract a subset of an array collection


"nikos101" <webforumsuser@macromedia.com> wrote in message
news:g95kq6$31b$1@forums.macromedia.com...
> Is there a way to extract a subset of an array collection where a
> particular
> value is found, without doing it manually
>
> EG {
> {t=4,s=3}
> { t=3,s=3}
> { t=3,s=3}
> }
>
> Extract where t = 3
>
> returns
>
> {
> { t=3,s=3}
> { t=3,s=3}
> }


filterFunction


Reply With Quote


  #4 (permalink)  
Old 08-28-2008, 03:15 PM
anirudhs
 
Posts: n/a
Diggs:
Default Re: Is there a way to extract a subset of an arraycollection

Well, if you set a filterFunction, you'd need to iterate through the
ArrayCollection to get the filtered version. Each iteration will cause an
execute to filterFunction.

You're better off manually iterating through the array.

Though, if you want the filtering to happen when you have a view attached to
your ArrayCollection like a datagrid or a list, then a filterFunction is the
best solution.

Reply With Quote
  #5 (permalink)  
Old 08-28-2008, 03:43 PM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Is there a way to extract a subset of an array collection


"anirudhs" <webforumsuser@macromedia.com> wrote in message
news:g96b39$qtu$1@forums.macromedia.com...
> Well, if you set a filterFunction, you'd need to iterate through the
> ArrayCollection to get the filtered version. Each iteration will cause an
> execute to filterFunction.


No, you just call yourAC.refresh() after applying the filter. Then any
references to yourAC will only show the filtered data.

HTH;

Amy


Reply With Quote
  #6 (permalink)  
Old 08-29-2008, 05:26 AM
anirudhs
 
Posts: n/a
Diggs:
Default Re: Is there a way to extract a subset of an arraycollection

Exactly. yourAC.refresh() is what calls the filterFunction for each element in
the array:

This is from mx.collections.ListCollectionView:

if (filterFunction != null)
{
var tmp:Array = [];
var len:int = localIndex.length;
for (var i:int = 0; i < len; i++)
{
var item:Object = localIndex[i];
if (filterFunction(item))
{
tmp.push(item);
}
}
localIndex = tmp;
}

This is the code that gets executed when you set a filterFunction and call
refresh. This "iteration" is what I was referring to in my previous post. Sorry
if it wasn't very clear.

You generally do not want to do so much if all you want is a subset from the
array collection without the arraycollection being mapped to a view or
something.

HTH,
Anirudh Sasikumar

Reply With Quote


Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 02:42 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk