If you want a checkbox to control the visibility of another component, what
you want is binding. Off the top of my head (and unlikely to compile):
<mx:CheckBox id="cb" label="Show / Hide"/>
<ns:SomeComponent visible="{ cb.selected }" includeInLayout="{
cb.selected}"/>
As for Flex keeping a flat list, I seriously doubt it. I imagine it
traverses the tree as a doubly linked list. You don't need recursion to to
this sort of thing either, by the way as the displaylist is (AFAIK) a tree
and not a network. Also typed off the top of my head in gmail, and probably
won't compile:
function visitAllChildren(parent:UIComponent, visitor:Visitor):void {
var currentChildren:Array = getAllChildren(parent); //getAllChildren is
imaginary helper method
while (currentChildren.length > 0) {
var nextChildren:Array = [];
for each (var child:UIComponent in currentChildren) {
visitor.visit(child);
nextChildren.push(getAllChildren(child));
}
currentChildren = nextChildren;
}
}
-Josh
}
On Wed, Jul 2, 2008 at 5:36 PM, pbrendanc <[EMAIL PROTECTED]> wrote:
> Hopefully I won't need to - however old habits die hard -maybe a
> FAQ/guide for some of us older client/server developers would be useful
> - Flex is a different way of thinking/different mindset.
>
> I think you just turned on a light bulb for me - using loosely coupled
> events can accomplish the same thing w/out needing to locate specific
> controls etc. (Imagine a scenario in a data entry app were a checkbox
> click requires the enabling/disabling of a group of related controls -
> registering and handling events is the Flex way - different than what
> I'm used to).
>
> BTW - Managing a separate list in the manner you described seems
> redundant (unless there is performance penalty) - I'd expect the Flex
> framework to make that data readily available. Recursion is a bit
> counter intuitive.
>
> Again, I'm new to Flex and with a better understanding of the framework
> I may well see problems/solutions etc in a different light.
>
> Thx for your response - so much to learn!
>
> Patrick.
>
> --- In [email protected], "Josh McDonald" <[EMAIL PROTECTED]> wrote:
> >
> > I'd attach an event listener to systemManager which listens for
> bubbling
> > flash.events.Event.ADDED and flash.events.Event.REMOVED events and
> keeps a
> > list. You will of course have to attach said event listener on
> > Application.preinitialize or something like that.
> >
> > I'm interested into why you'd want to do this though?
> >
> > -Josh
> >
> > On Wed, Jul 2, 2008 at 1:37 PM, pbrendanc [EMAIL PROTECTED] wrote:
> >
> > > In windows apps there is a control array collection that can be used
> > > to find controls and return a handle to the appropriate object.
> > >
> > > What is the recommended Flex approach to finding controls and are
> > > there any performance tradeoffs here - recursion is slow and
> > > potentially error prone (stack overflows anyone?)??
> > >
> > > (I'm seeing the use of recursive GetChildByName calls in some
> examples
> > > and wonder if there is a more direct way to find a control given the
> > > name/ID - regardless of the nesting level). Am I correct in thinking
> > > that GetChildByName only searches the current node for an item,
> rather
> > > than subordinate, nested items?
> > >
> > > TIA,
> > > Patrick
> > >
> > >
> > >
> >
> > --
> > "Therefore, send not to know For whom the bell tolls. It tolls for
> thee."
> >
> > :: Josh 'G-Funk' McDonald
> > :: 0437 221 380 :: [EMAIL PROTECTED]
> >
>
>
>
> ------------------------------------
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> Links
>
>
>
>
--
"Therefore, send not to know For whom the bell tolls. It tolls for thee."
:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]