Flex horizontal layout that wraps to the next line? - apache-flex

Is there a Flex layout class that wraps to the next line and does not size all the items the same size?
I've tried using TileLayout but the problem with that is that all the items are sized to the largest item. I want to set the gap between each to be consistent. Basically a variableColumnWidth type of feature.
<s:List id="exampleList"
selectedIndex="0"
width="100%"
dataProvider="{examplesCollection}"
change="exampleList_changeHandler(event)"
height="250"
>
<s:layout>
<s:TileLayout verticalGap="0" horizontalGap="0" />
</s:layout>
</s:List>
I'm using Apache Flex 4.12.

I think that the quickest way would be to implement an item renderer, like this example. The other option is to implement your own layout which you can adapt to what you need, for this you need to understand very well how layouts work.

Related

What is the best view architecture in flex?

I have started learning flex 4 and I got myself thinking about how to change views. So I have a question what do people usually use - states or views (ViewStack). The type of web application I am making, can use both, but what do developers use in big projects or maybe they use non of the mentioned before?
Also I have a question about ViewStack. If I write:
<mx:ViewStack id="views" resizeToContent="true" verticalCenter="0" horizontalCenter="0" >
<s:NavigatorContent id="navOne">
<s:Label text="asdas" x="0" y="0"/>
</s:NavigatorContent>
then I can't change location of its child. Label remains in the center of the screen. If I remove vertical and horizontal center from ViewStack and put them in Label's tags, then label will be in top left corner but not in center. How do I control those locations?
As far as you're using Flex 4 you can prefer states. And there are at least two reasons for that:
Flex 4 states are much more declarative than in Flex 3.
Flex 4 hasn't Spark implementation of ViewStack and it is rather obsolete (necessarity of using NavigatorContent with Spark container is another proof of that fact).
The second part of the question. The problem is your ViewStack hasn't any size. So finally it has size of content (Label size). So verticalCenter and horizontalCenter are just alignment of your ViewStack. To control size and alignment of ViewStack you should care about sizes. Something like:
<mx:ViewStack id="views" resizeToContent="true" verticalCenter="0"
horizontalCenter="0" width="500" height="300" >
<s:NavigatorContent id="navOne" width="100%" height="100%">
<s:Label text="asdas" x="0" y="0"/>
</s:NavigatorContent>

Add padding to a titlewindow in Flex 4 (ideally using skins)?

By default TitleWindows seem to have no padding. I tried the properties "left", "right" etc and it doesn't work. Actually I'd like to have a default for my whole app, so I tried creating a skin but no matter where in the skin I add 'left="50"' it just doesn't create padding on the left. You'd think that you should add it to the element with id="contentGroup", as described on this Adobe Skinning help page, but that does not work.
Surely this is something almost everyone wants to do?
The contentGroup in the default TitleWindowSkin is inside a VerticalLayout which does not respect top/left/right/bottom constraints.
You could do this by duplicating the default TitleWindowSkin and wrapping the contentGroup with a Group with width/height of 100%:
...
<s:Group width="100%" height="100%">
<!--- #copy spark.components.SkinnableContainer#contentGroup -->
<s:Group id="contentGroup" top="10" left="10" right="10" bottom="10" minWidth="0" minHeight="0" />
</s:Group>
...
Since the TitleWindow extends the Panel component, it doesn't support the padding properties a HGroup or VGroup based component would. As far as I know, there's no way to skin a TitleWindow so that the padding properties are automatically set.
All I do is set the x and y coordinates of my components within the TitleWindow so that they are laid out where I want them.

Flex Advanced data grid wordwrapping

I have an AdvancedDataGrid component, which has AdvancedDataGridColumn's that are rendered using MXAdvancedDataGridItemRenderer. When user stretches any columns, I want all rows to adjust it's height. So, I set variableRowHeight to true and wordWrap to true.
The problem is that it doesn't always readjust its height. Stretching a column will cause it to overflows into another row. Now, if i just click on the column separator, it will readjust. So basically, first stretching it and then just clicking on column separator solves the overflow problem.
Anyone encounter this overflow issue before?
Update
Step1 (Initial):
Step2 (After first re-size):
Step3 (After clicking on column separator):
ItemRenderer:
<fx:Component className="nameRenderer">
<s:MXAdvancedDataGridItemRenderer width="100%">
<s:layout>
<s:HorizontalLayout />
</s:layout>
<mx:Image source="application/documentManager/mimeTypeIcons/{data.img}" toolTip="{data.tooltip}"
horizontalCenter="0" verticalCenter="0" />
<mx:Text top="5" left="5" right="5" bottom="5" text="{data.data.name}" toolTip="{data.tooltip}" width="100%" />
</s:MXAdvancedDataGridItemRenderer>
</fx:Component>
in my last project, i did a lot with the adg.
But i never had this issue. Can you give me a Screenshot?
I had some probems with the scrollbars. After installing FlashBuilder Burrito with the hero-SDK, this issue gone away.
They did a few things with adg and the dg is now also available as a spark.
Probably this will solve your issue?
BR
Frank

Flex 4.1: <mx:List> had rowCount properly for the limit the displayed items. <s:List> doesn't

Hi I'm using flex 4.1 to write an application.
i read in the documents that has the rowCount property to set how many items to display. the does not have that property.
how can I limit the list to display 3 items ?
you can directly set requestedMinRowCount to 3 in the VerticalLayout
<s:List>
<s:layout>
<s:VerticalLayout requestedMinRowCount="3"/>
</s:layout>
</s:List>
In Flex 4 this is driven by the skin rather than the component itself. You can create a custom List skin and in the VerticalLayout of the DataGroup, set the requestedRowCount to 3, then set the skin for your List to be your new custom skin. To get started, just copy the default ListSkin into your custom skin file and make your changes. Here's the relevant section from the default ListSkin file:
<s:DataGroup id="dataGroup" itemRenderer="spark.skins.spark.DefaultItemRenderer">
<s:layout>
<!--- The default layout is vertical and measures at least for 5 rows.
When switching to a different layout, HorizontalLayout for example,
make sure to adjust the minWidth, minHeihgt sizes of the skin -->
<s:VerticalLayout gap="0" horizontalAlign="contentJustify" requestedMinRowCount="5" />
</s:layout>
</s:DataGroup>
Just remove requestedMinRowCount and replace it with requestedRowCount="3" Hope that helps.
Thanks Wade for the great answer, it put me on the right path.
Actually you don't need to copy the default skin, if it's only the row count you want to fix Just use the tag inside the tag to control the minimum row count like Wade described.

Centering Content in Flex 4

I'm building a custom component that extends SkinnableContainer. I can center the content either vertically or horizontally inside it, but not both-- and that is what I need.
I'm setting the layout to HorizontalLayout for the component and setting verticalAlign to middle.
Then I'm creating a canvas to surround another component that goes inside this component, and setting that canvas width to 100%, and then setting textAlign=center, but no dice.
Any help is appreciated.
Use the horizontalCenter and verticalCenter properties to center your groups. The value is the number of pixels from either center where the sign of value denotes direction, 0 is absolute center.
This'll do the trick (assuming you want horizontal layout for your items). The 's' namespace refers to the spark components, since you're asking about flex 4 I assume Halo isn't of interest.
<s:Group>
<!-- Any parent with BasicLayout will acknowledge horizontalCenter and verticalCenter -->
<s:layout>
<s:BasicLayout />
</s:layout>
<s:Group horizontalCenter="0" verticalCenter="0">
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<s:Button />
<s:Button />
<s:Button />
</s:Group>
</s:Group>

Resources