No, this is one reason Repeater is overlooked, that is is associated
with lists or other containers.  In fact it is not associated with any
container, and does not do any layout at all, but just creates and
removes components.

 

Use Repeater in a canvas, and you have full control over positioning by
setting the x,y.  And reposition them dynamically just by updating the
dataProvider

 

Further, if you are repeating complex components, declare them in a
custom Component, and repeat that.  Pass in a reference to the
dataProvider currentItem, and you can code the custom component
normally, intuitively, without worying about getRepeaterItem, finding
repeated children, referencing sub-components, etc.  Plus such a
component can dispatch an event, and the handler can have access to all
of the data that produced it.

 

If you use Repeater in a Vbox with a custom component, then that
component can have a variable size, and the vbox will layout the
children accordingly.

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Justin Winter
Sent: Tuesday, November 27, 2007 12:49 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: This has to be a bug right? If not, please
explain...

 

Tracy, thanks for the feedback. The above was just an example of an
issue I ran into while trying to build a larger menu component.
I don't have much experience with the mx:Repeater control so
I will look into it more. 

I originally tried to build the component using MXML and nested
containers, but one of the main issues I ran into was that all box
containers, and I think the repeater falls into this category too,
position their child elements based on the childIndex value. This is
undesirable in my case. For instance, if I have three buttons stacked
on top of each other vertically (think List control), I need button 1
to have a dropshadow on top of button 2. 

I've been contemplating subclassing VBox to see if I can override the
positioning logic but I ran into the above issue and need to figure
out the best solution to get the height of a container after
dynamically adding children so I can reposition other UIComponents at
runtime based on the UIComponent's height. 

Seems like I'm missing something simple here...

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> For creating multiples of the same component, consider using
> mx:Repeater. It handles many ugly details for you. If, for example,
> you wanted to remove the children you created using addChild, it would
> take some thought and some code, further complicated if there are
static
> components in the container as well. With Repeater, just do:
> myRepeater.dataProvider.removeAll();
> 
> Tracy
> 
> 
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Alex Harui
> Sent: Tuesday, November 27, 2007 12:14 PM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: RE: [flexcoders] This has to be a bug right? If not, please
> explain...
> 
> 
> 
> Flex uses an invalidation mechanism. As properties change, flags are
> set requesting validation of those properties at a later time. You can
> force validation by calling validateNow(), but it can be expensive.
> 
> 
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Justin Winter
> Sent: Tuesday, November 27, 2007 9:10 AM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] This has to be a bug right? If not, please
> explain...
> 
> added to a creationComplete handler function:
> 
> <code>
> var vBox:VBox = new VBox();
> 
> for(var i:int = 0; i < 10; i++)
> {
> var tmpBtn:Button = new Button();
> tmpBtn.label = "BUTTON: " + i;
> vBox.addChild(tmpBtn); 
> }
> 
> this.addChild(vBox);
> 
> trace('VBOX HEIGHT: ' + vBox.height);
> </code>
> 
> OUTPUT:
> ------
> VBOX HEIGHT: 0 <- ALWAYS ZERO
> 
> No matter if I call vBox.invalidateProperties(); or any of the other
> invalidate functions. The buttons are added to the container fine and
> are displayed fine. 
> 
> I've also tried this with several other containers and the height is
> not updated after the children are added. What am I missing here?
>

 

Reply via email to