Flex 4 resize groups within a group - apache-flex

I am trying to automatically resize the children within an s:Group. The children are another s:Group and a H:Group. Each have a percentage width of 10% and 90% each. The problem is that when one of the groups is resized (using a transition and rotation combination in the Skin), the other group does not automatically resize to fill the space?
Shouldn't Flex do this automatically? or do I have to code this?
<s:Group
id="listsGroup"
width="100%"
height="255"
>
<s:Label text="LIST WITH HEADER TEST" styleName="h1" />
<s:Group
id="listsGroupSavedSearches"
width="10%"
height="255"
>
<components1:ListWithHeader
id="categories11"
dataProvider="{listModel}"
headerLabel="Saved Searches"
allowMultipleSelection="true"
top="10" bottom="0"
left="0" width="10%"
/>
</s:Group>
<s:HGroup left="160" width="90%" height="150" top="50" gap="6">
<components1:ListWithHeader
id="categories1"
dataProvider="{listModel}"
headerLabel="Category1 "
allowMultipleSelection="true"
width="100%"
height="150"
/>
<components1:ListWithHeader
id="categories2"
dataProvider="{listModel}"
headerLabel="Category2"
allowMultipleSelection="true"
width="100%"
height="150"
/>
<components1:ListWithHeader
id="categories3"
dataProvider="{listModel}"
headerLabel="Category3"
allowMultipleSelection="true"
width="100%"
height="150"
/>
</s:HGroup>
</s:Group>

The best way to approach something like this is to tie into the Flex Component lifecycle methods, specifically updateDisplayList(). UpdateDisplayList() is used to position and size your children. It has two parameters, the height and width of your component. You can then write an algorithm to size and position your children based on the component's height and width.
MXML does this all under the hood, kind of in a black magic sort of way; but you'll gain more control if you write the layout code yourself.

Related

Flex 4 scroller with group. Scrollbars not showing up

I know I have done this before but every time I work with scrollers and group it doesn't work for me and kills my 2 days.
<s:Scroller width="100%" height="100%" horizontalScrollPolicy="auto" verticalScrollPolicy="auto">
<s:Group clipAndEnableScrolling="true">...... ..... </s:Group></s:Scroller>
This is what I have. I have components inside my group with is more than enough to bring scrollers even on a big monitor. But I am not getting any scrollbars.
Kindly tell me what is that I am doing wrong here. because everytime I fix it and I struggle for the next time.
Thanks.
Try with this
Your scroller parent container need to set non-percentage height/width.
<s:BorderContainer width="120" height="100" backgroundColor="#FFFFFF">
<s:Scroller width="100%" height="100%">
<s:Group>
<s:layout>
<s:VerticalLayout horizontalAlign="justify"
clipAndEnableScrolling="true" />
</s:layout>
<s:Button label="button (1)" />
<s:Button label="button (2)" />
<s:Button label="button (3)" />
<s:Button label="button (4)" />
<s:Button label="button (5)" />
<s:Button label="button (6)" />
</s:Group>
</s:Scroller>
</s:BorderContainer>
Thank you for all your responses. After setting the minHeight it now works. I am able to achieve the scrollbars as expected (make it look like browser's scroll bar). Below is the code snippet
<s:Scroller width="100%" maxHeight="{this.height}">
<s:VGroup width="100%" minHeight="1000" height="100%" paddingLeft="40" paddingRight="40" paddingTop="0" >
..</s:VGroup></s:Scroller>
Kindly let me know if there is a better approach.
The Same code given by "Raja Jaganathan" itself will work with small modification on scroll parent height and width
Capabilities.screenResolutionX, Capabilities.screenResolutionY will give you the browser width and height respectively.

s:Group arrange component on the same center

I use a s:Group to place my component in my form.
I'd like all form item have the same horizontal align inside the group.
I try to use horizontalcenter with value 0 but it doesn't work.
So I don't know how to do and I hope you can help me to solve that.
<s:Group width="100%" resizeMode="noScale" verticalCenter="0" horizontalCenter="0">
<s:FormItem label="Naissance" tabIndex="5" x="{cbQualite.x}" id="fiNaissance">
<mx:DateField id="dfNaissance" width="100" editable="true"
formatString="DD/MM/YYYY" yearNavigationEnabled="true"
/>
</s:FormItem>
<s:RadioButton id="rbFem" label="FĂ©minin" group="{rbsex}" tabIndex="7"
x="{fiNaissance.x + fiNaissance.width+5}"
/>
<s:RadioButton id="rbMas" label="Masculin" group="{rbsex}" tabIndex="6" x="{rbFem.width + rbFem.x + 5}" y="{fiNaissance.y +(fiNaissance.height)/2}"/>
<s:DropDownList id="cbDossier2" dataProvider="{DP_PAT_DOS1}" width="118" height="22" tabIndex="8" x="{cbDossier1.x}"/>
<s:FormItem label="" tabIndex="9" x="{fiDossier1.x}" >
<s:TextInput id="fDossier2" width="90" paddingRight="5" text="#{objectPatient.paDossier2}" />
</s:FormItem>
</s:Group>
What do you mean by same horizontal align ?
If you want elements inside Group to be centered horizontally you must put horizontalCenter="0" not on the parent but on each child.
Furthermore it is a mistake to specify width="100%" and horizontalCenter="0" both on Group.
width="100%" indicates your Group will take all horizontal space in the parent container if the parent container layout support it. Your Group will automatically be centered.
Put all parts of the forms inside FormItems, and put all the FormItems inside a Form.

flex <mx:List> is hidden by other UI component

In flex UI, my <mx:list> can not be shown completely because of other component shelterring (for example: the refresh button shelter part of it ). How can I make the <mx:list> in front of all other UI component.
This is my code:
<s:HGroup verticalAlign="middle">
<s:Label text="Choose Log File"/>
<mx:ComboBox id ="logFileChooseCombo" dataProvider="{fileNameList}" width="150" color="0x000000"
close="changeLogFilesHandler(event);"/>
<mx:Spacer width="320" />
<s:Label text="Filter or HighLight:" />
<mx:ComboBox id ="filterChooseCombo" dataProvider="{filterOrHighlight}" width="150" color="0x000000"/>
<s:VGroup height="25">
<s:TextInput id="logContentInput" change="filterLogContent()"
enabled="true"
focusIn="clearMyTextInput()"
text="Filter/HightLight"
width="250" height="26"/>
**<mx:List id="searchMsgList"** x="65" y="35" width="200" height="200" fontSize="12"
change="itemChangEvent(event);" />
</s:VGroup>
</s:HGroup>
</mx:Canvas>
<s:HGroup verticalAlign="middle">
<s:Label text="Filter By Log Level:"/>
<mx:ComboBox id ="logLevelCombo" dataProvider="{logLevelsInt}" width="150" color="0x000000"
close="changeLogLevelHandler(event);"/>
<s:CheckBox id="showStack" click="showStackTrace(event)" selected="false"/>
<s:Label text="show stackTraces"/>
<mx:Spacer width="550" />
<s:Button id="test" label="refresh2">
</s:Button>
</s:HGroup>
You have a lot going on, with a mix of nested layouts and a mix of Halo and Spark containers. I'm not sure what layout you're trying to create.
That said, take a look at the swapChildren method. Something like this should work:
this.swapChildren(refresh2, searchMsgList);
But it will most likely hide your refresh button, which seems less than ideal.
A few things strike me:
Inside your first VGroup you have x and y values specified. I thought those values were ignored inide VGroups, which automatically position your children in a vertical line.
I see an closing </mx:Canvas> tag, but not an opening canvas tag. It is unusual to me to use a canvas among all the HGroups and VGroups.

using constraint layout and percentage layout together flex

I'm trying to use percentage based layout along with contraint based layout to achieve the following layout
http://imgur.com/rgoBe.jpg
I have 3 canvas set in my app with the correct percentages but I setting things like top=10 left = 10 to create "border margins" has no effect.
How can I fix this?
EDIT
<containers:GradientVBox width="820"
height="625"
id="vbox">
<containers:GradientCanvas width="100%"
height="25%"
id="wave"
click="collapseWaveform(event)"
buttonMode="true" cornerRadiusBottomLeft="16"
cornerRadiusBottomRight="16"
cornerRadiusTopLeft="8"
cornerRadiusTopRight="8"
gradientFrom="0xffffff"
gradientTo="0xf5f5f5" top="10" />
<mx:HBox width="100%"
height="75%"
id="myhbox"
paddingTop="0">
<containers:GradientCanvas width="50%"
height="100%"
alpha="1.0"
id="left"
buttonMode="true" cornerRadiusBottomRight="8"
cornerRadiusTopLeft="8"
cornerRadiusTopRight="8"
gradientFrom="0xffffff"
gradientTo="0xf5f5f5" left="10">
<content:Content width="95%"
height="95%"
id="content"
verticalCenter="0"
horizontalCenter="1"
horizontalScrollPolicy="off"
resize="resizeIt()">
<mx:ViewStack id="contentviewstack"
width="100%"
height="100%">
<containers:ContentContainerSoundCloud id="soundcloudcontent"
width="100%"
height="100%"
cornerRadius="5"
borderThickness="0"
borderStyle="solid"/>
<containers:ContentContainerLoopMasters id="loopmasterscontainer"
cornerRadius="5"
borderThickness="0"/>
<containers:ContentContainerClips id="clipscontents"
cornerRadius="5"
borderThickness="0"/>
</mx:ViewStack>
</content:Content>
</containers:GradientCanvas>
<containers:GradientCanvas width="50%"
height="100%"
id="right"
buttonMode="true" cornerRadiusBottomRight="8"
cornerRadiusTopLeft="8"
cornerRadiusTopRight="8"
gradientFrom="0xffffff"
gradientTo="0xf5f5f5" right="10" left="10"/>
</mx:HBox>
</containers:GradientVBox>
</mx:Application>
To add the gap at the top, set top="10" on vbox, not wave.
To get the 10 pixel gap in the middle, set gap="10" on vbox.
To get the 10 pixel gap on the right, set right="10" on vbox.
That should create the layout you're looking for.

Issues displaying the Background in VBox while using WindowShader

I am using a WindowShader in my website. every thing is working fine. but for somereason i am unable to display any background for my "home_feeds" VBox. If i add components on it, i can see them. But they backgound is not working. Even if i remove every thing from the Canvas(with home_feeds) i still dont see any background. But if i remove the comments from my mx:List.. i can see the background.
my code is given below
<mx:VBox right="35" paddingRight="10" verticalAlign="top" horizontalAlign="right">
<containers:WindowShade id="shade" opened="false" openIcon="{null}" closeIcon="{null}" paddingTop="0"
headerLocation="bottom" visible="true">
<containers:headerRenderer>
<mx:Component>
<flexlib:CanvasButton width="100%" height="20" skin="mx.skins.ProgrammaticSkin">
<mx:Script>
<![CDATA[
import flexlib.containers.WindowShade;
]]>
</mx:Script>
<mx:Box width="100%" horizontalAlign="center">
<degrafa:Surface width="80">
<degrafa:GeometryGroup>
<geometry:EllipticalArc closureType="pie"
arc="180" startAngle="-180" width="80" height="35" y="-18">
<geometry:fill>
<paint:GradientFill angle="90">
<paint:GradientStop color="#920000" />
<paint:GradientStop color="#D31F1F" />
</paint:GradientFill>
</geometry:fill>
</geometry:EllipticalArc>
<geometry:Polygon>
<geometry:data>40,5 35,13 45,13</geometry:data>
<geometry:stroke>
<paint:SolidStroke color="#333333" alpha="{WindowShade(parent).opened ? 1 : 0}" weight="1" />
</geometry:stroke>
<geometry:fill>
<paint:SolidFill color="#ffffff" alpha="{WindowShade(parent).opened ? 1 : 0}" />
</geometry:fill>
</geometry:Polygon>
<geometry:Polygon>
<geometry:data>40,13 35,5 45,5</geometry:data>
<geometry:stroke>
<paint:SolidStroke color="#333333" alpha="{WindowShade(parent).opened ? 0 : 1}" weight="1" />
</geometry:stroke>
<geometry:fill>
<paint:SolidFill color="#ffffff" alpha="{WindowShade(parent).opened ? 0 : 1}" />
</geometry:fill>
</geometry:Polygon>
</degrafa:GeometryGroup>
</degrafa:Surface>
</mx:Box>
</flexlib:CanvasButton>
</mx:Component>
</containers:headerRenderer>
<mx:Canvas horizontalScrollPolicy="off" width="200" height="350" >
<!--mx:List id="home_feeds" height="100%" width="100%" itemRenderer="file_manager.list_item_template" doubleClickEnabled="true" /-->
<mx:VBox id="home_feeds"
width="100%"
backgroundAlpha="0.1"
left="10"
right="10">
</mx:VBox>
</mx:Canvas>
<containers:filters>
<mx:DropShadowFilter alpha=".3" angle="90" />
</containers:filters>
</containers:WindowShade>
</mx:VBox>
Kindly let me know what am i doing wrong here.... And how can i fix it. I want to use the VBox there.
Regards
Zeeshan
The size of a VBox without an explicit value for width would be zero if it doesn't have any children in it. Add some children (a Label for example) to see the background color. Increase background alpha from 0.1 to 0.5 or something to see it clearly.
If you mention explicit values for width and height (instead of percentages), you can see the background color even if it doesn't have any children.
set backgroundColor="#00ff00" (green) for the home_feeds VBox to differentiate VBox's background color from its parent's color.

Resources