I'll have to take your word on that, but I'm still skeptical.  If what you say is true, then you could still use the same approach, but instead have the view listen for updates to the masterArray in the ModelLocator.  You could do this either by using the changWatcher utility or Paul Williams' Observe tag:

http://weblogs.macromedia.com/paulw/

When your view hears a change to the masterArray, you would then refresh the ArrayCollection.  It's a little cumbersome, but since direct binding doesn't want to work for you, it might be a necessary step.

-TH

--- In flexcoders@yahoogroups.com, "Tom Bray" <[EMAIL PROTECTED]> wrote:
>
> Thanks for trying. An ArrayCollection will not reflect changes made
> directly to its source array, so new items pushed onto masterArray do not
> show up in my views.
>
> -Tom
>
> On 6/9/06, Tim Hoff [EMAIL PROTECTED] wrote:
> >
> > Changes to the masterArray in the ModelLocator should be
> > automatically reflected in the AC if you use either of the binding
> > methods I posted. If not, sorry. That's all I have.
> >
> >
> > -TH
> >
> > --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, "Tom
> > Bray" tombray@ wrote:
> > >
> > > The problem is that changes to ModelLocator.getInstance
> > ().masterArray don't
> > > update the views' dataProviders. In other words, the
> > ArrayCollections that
> > > use masterArray as their source don't know when new items are
> > added to or
> > > removed from masterArray. That's why I was thinking that
> > masterArray would
> > > actually be masterArrayCollection and I'd bind each of the view's
> > > dataProvider ACs to it so they could stay in sync. I bound the
> > master AC to
> > > the sub ACs using BindingUtils and was surprised to see the filter
> > function
> > > on the sub ACs affect the master AC. I posted sample code here:
> > > http://groups.yahoo.com/group/flexcoders/message/39064?l=1
> > >
> > > Thanks again!
> > >
> > > -Tom
> > >
> > > On 6/9/06, Tim Hoff TimHoff@ wrote:
> > > >
> > > >
> > > > Something like this should do the trick:
> > > >
> > > > <mx:Script>
> > > > <![CDATA[
> > > >
> > > > import mx.collections.ArrayCollection;
> > > > import org.ets.main.code.model.ModelLocator;
> > > >
> > > > [Bindable]
> > > > public var viewDataProvider : ArrayCollection;
> > > > viewDataProvider=new
> > > > ArrayCollection({ModelLocator.getInstance().masterArray});
> > > >
> > > > ]]>
> > > > </mx:Script>
> > > >
> > > > -TH
> > > >
> > > >
> > > > --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com><flexcoders%
> > 40yahoogroups.com>, "Tom
> > > > Bray" <tombray@> wrote:
> > > > >
> > > > > Thanks, Tim. That makes sense but there's one limitation I'm
> > not sure
> > > > how
> > > > > to work around. That master Array of users is going to be
> > constantly
> > > > updated
> > > > > by the server to show who's currenlty online. Since an Array
> > isn't
> > > > > bindable, how would you propagate changes from that Array to
> > the
> > > > filtered
> > > > > ArrayCollections that use it as their source?
> > > > >
> > > > > -Tom
> > > > >
> > > > > On 6/9/06, Tim Hoff TimHoff@ wrote:
> > > > > >
> > > > > > Hey Tom,
> > > > > >
> > > > > > In response to this question and the BindingUtils and
> > > > > > ArrayCollection.filter question, I offer this suggestion. In
> > the
> > > > > > ModelLocator maintain a single master Array of all the
> > users. Then
> > > > > > in each instance of your view components, create a new bound
> > > > > > ArrayCollection (dataProvider), with the master Array as the
> > > > > > underlying source. Each of the ArrayCollections will have a
> > > > > > different filterFunction based on the type of view component
> > that is
> > > > > > instantiated. Because the ArrayCollections don't actually
> > contain
> > > > > > any data, just pointers to the underlying Array, I would
> > handle the
> > > > > > ArrayCollections and filterFunctions in viewHelpers. In a
> > sense,
> > > > > > you would be creating separate sub-sets of the master Array
> > in each
> > > > > > instance of your views. If you preferred, you could maintain
> > each
> > > > > > ArrayCollection (Array of ArrayCollections) in the
> > ModelLocator as
> > > > > > well.
> > > > > >
> > > > > > I hope that this makes sense,
> > > > > > Tim Hoff
> > > > > >
> > > > > >
> > > > > > --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com><flexcoders%
> > 40yahoogroups.com><flexcoders%40yahoogroups.com>,
> >
> > > >
> > > > "Tom
> > > > > > Bray" tombray@ wrote:
> > > > > > >
> > > > > > > Say my model has an ArrayCollection of all the users that
> > are
> > > > > > > connected to my Flex app. I then have configurable list
> > views that
> > > > > > > display different subsets of that collection based on
> > different
> > > > > > user
> > > > > > > properties (gender, age, location, etc.). Multiple views,
> > multiple
> > > > > > > filters, all being fed from the same master
> > ArrayCollection of all
> > > > > > > connected users. I even want the user to be able to
> > dynamically
> > > > > > > create new views with different filters.
> > > > > > >
> > > > > > > Unless there's something I'm missing, each view is going
> > to need
> > > > > > its
> > > > > > > very own ArrayCollection that has its own filter function
> > set up.
> > > > > > I'm
> > > > > > > picturing a wrapper class that provides addFilter() and
> > > > > > removeFilter()
> > > > > > > methods so that the AC's filter function can traverse an
> > array of
> > > > > > > other filters -- kind of a CompoundCommand pattern.
> > > > > > >
> > > > > > > Assuming that's part of the correct approach, I want my
> > master AC
> > > > > > to
> > > > > > > pump changes out to the filtering ACs which pump changes
> > out to
> > > > the
> > > > > > > views. Is there a way to make the binding mechanism work
> > for this?
> > > > > > > Is there a simpler approach I'm overlooking?
> > > > > > >
> > > > > > > Any tips you can send my way would be greatly appreciated.
> > > > > > >
> > > > > > > Thanks,
> > > > > > >
> > > > > > > Tom
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> >
> >
> >
>

__._,_.___

--
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




__,_._,___

Reply via email to