jjeje
IT WORKS!!!
I can now build my UI declaratively from an XML spec...
needs some tweaking to allow runtime reassignment of the condition
property... but is fine for one time generation ( or within a
repeater. dirty trick )
i forgot to call validateNow() after creating the child
On 5/31/07, Aldo Bucchi <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> The component below gets to instantiate its chid correctly but it
> doesn't show up in the displaylist.
>
> any clues??
>
> package foo.conditionals
> {
> import mx.containers.HBox;
>
> /**
> *
> * Does not support changing the condition property at runtime yet
> *
> * @author abucchi
> *
> */
> public class ConditionalContainer extends HBox
> {
>
> private var _condition:Boolean;
>
> public function get condition():Boolean
> {
> return _condition;
> }
>
> public function set condition( value:Boolean ):void
> {
> _condition = value;
> }
>
> override public function createComponentsFromDescriptors(
> recurse:Boolean = true ):void
> {
>
> if ( childDescriptors.length == 0 )
> return; // no children specified
>
> if ( condition ) // condition met, create first child
> {
> createComponentFromDescriptor(
> childDescriptors[0] , recurse );
> }
> else if ( childDescriptors.length == 2 ) // not met,
> create second
> child if specified
> {
> createComponentFromDescriptor(
> childDescriptors[1] , recurse );
> }
>
> }
>
> }
>
> }
>
>
>
> <mx:Repeater id="rep" dataProvider="{[0,1,2,3,4,5]}">
>
>
> <conditionals:ConditionalContainer
> condition="true"
> paddingBottom="0" paddingLeft="0" paddingRight="0"
> paddingTop="0"
> >
>
> <mx:Label text="first label" creationComplete="trace('first
> label created')"/>
>
> <mx:Label text="second label" creationComplete="trace('second
> label
> created')"/>
>
> </conditionals:ConditionalContainer>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> On 5/31/07, Aldo Bucchi <[EMAIL PROTECTED]> wrote:
> > ok,
> >
> > just realized that you can accomplish something similar by using
> > navigators... just set creationPolicy="auto" and conditionally set the
> > selectedIndex... only it will just work under some particular
> > circumstances and is quite hacky.
> >
> > i need to destroy children when the condition changes, to avoid
> > parameter problems... but still. that only leaves me with binding
> > issues.
> >
> > OTOH, the ideal way would be to create a custom component that
> > implements IRepeater so that containers don't add it, and then play
> > with createChildrenFromDescriptors and such.
> >
> > i just gave the latter a try and got it kinda working, but it would
> > take toooooooooo much time to make it work with bindings and stabilize
> > it. i give up.
> >
> > c'mon adobe guys!
> > you can do it ;)
> >
> > best,
> > Aldo
> >
> > On 5/31/07, Aldo Bucchi <[EMAIL PROTECTED]> wrote:
> > > Hi Guys,
> > >
> > > Has anyone flirted with the idea of creating MXML
> > > conditional-structure components that can be used to dynamically
> > > generate interfaces??
> > >
> > > just to be more graphical... something like this
> > >
> > > <mx:Repeater id="rep2" dataProvider="{rep1.currentItem.elements('*')}">
> > >
> > > <foo:If condition="[EMAIL PROTECTED]'super'}">
> > >
> > > <foo:SuperLabel text="[EMAIL PROTECTED]"/>
> > >
> > > <foo:Else>
> > >
> > > <mx:Label text="[EMAIL PROTECTED]"/>
> > >
> > > </foo:Else>
> > >
> > > </foo:If>
> > >
> > > </mx:Repeater>
> > >
> > > it just makes a lot of sense...
> > > any ideas????
> > >
> > > best,
> > > Aldo
> > >
> > >
> > > --
> > > ::::: Aldo Bucchi :::::
> > > mobile +56 9 8429 8300
> > >
> >
> >
> > --
> > ::::: Aldo Bucchi :::::
> > mobile +56 9 8429 8300
> >
>
>
> --
> ::::: Aldo Bucchi :::::
> mobile +56 9 8429 8300
>
--
::::: Aldo Bucchi :::::
mobile +56 9 8429 8300