a tip for Flexbox of Flexlib–How to re-layout the children when the width of FlowBox is set to 100%

System-Box-Empty The width of FlowBox will be the sum of its children’s width, if the width of FlowBox is set to 100%. So FlowBox will never re-layout the children.

It’s simple to solve this problem, just bind the width of FlowBox to the width of its parent or other fixed number.

Full code after the jump(Download full project Downloadhere).

Download: PureApp.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application
  3.     xmlns:mx="http://www.adobe.com/2006/mxml"
  4.     xmlns:local="*"
  5.     creationComplete="initApp()"
  6.     layout="vertical">
  7.     <mx:Script>
  8.         <![CDATA[
  9.             import mx.controls.Alert;
  10.            
  11.             private function initApp():void
  12.             {
  13.                 
  14.             }
  15.         ]]>
  16.     </mx:Script>
  17.     <mx:Panel width="100%" height="100%" id="parentPanel" title="BitsReader sample" layout="absolute">
  18.         <mx:Label text="width = parentPanel.width" />
  19.         <local:FlowBox borderStyle="solid" borderThickness="1" width="{parentPanel.width}" height="150" horizontalScrollPolicy="off" x="0" y="19">
  20.             <mx:HBox horizontalGap="1" >
  21.                 <mx:Text text="label1" fontSize="10"/>
  22.                 <mx:Text text="0000000000000000000" fontSize="10"/>
  23.             </mx:HBox>
  24.             <mx:HBox horizontalGap="1">
  25.                 <mx:Text text="label2" fontSize="10"/>
  26.                 <mx:Text text="0000000000000000000000000000000" fontSize="10"/>
  27.             </mx:HBox>
  28.             <mx:HBox horizontalGap="1">
  29.                 <mx:Text text="label13" fontSize="10"/>
  30.                 <mx:Text text="00000000000000000000000" fontSize="10"/>
  31.             </mx:HBox>
  32.             <mx:HBox horizontalGap="1">
  33.                 <mx:Text text="label4" fontSize="10"/>
  34.                 <mx:Text text="0000000000000000" fontSize="10"/>
  35.             </mx:HBox>
  36.             <mx:HBox horizontalGap="1">
  37.                 <mx:Text text="label5" fontSize="10"/>
  38.                 <mx:Text text="000000000000000000000000000" fontSize="10"/>
  39.             </mx:HBox>
  40.         </local:FlowBox>
  41.         <mx:Label text="width = 100%"  x="0" y="143"/>
  42.         <local:FlowBox borderStyle="solid" borderThickness="1" width="100%" horizontalScrollPolicy="off" x="0" y="169">
  43.             <mx:HBox horizontalGap="1" >
  44.                 <mx:Text text="label1" fontSize="10"/>
  45.                 <mx:Text text="0000000000000000000000000000000" fontSize="10"/>
  46.             </mx:HBox>
  47.             <mx:HBox horizontalGap="1">
  48.                 <mx:Text text="label2" fontSize="10"/>
  49.                 <mx:Text text="0000000000000000000000000000000" fontSize="10"/>
  50.             </mx:HBox>
  51.             <mx:HBox horizontalGap="1">
  52.                 <mx:Text text="label13" fontSize="10"/>
  53.                 <mx:Text text="0000000000000000000000000000000" fontSize="10"/>
  54.             </mx:HBox>
  55.             <mx:HBox horizontalGap="1">
  56.                 <mx:Text text="label4" fontSize="10"/>
  57.                 <mx:Text text="0000000000000000000000000000000" fontSize="10"/>
  58.             </mx:HBox>
  59.             <mx:HBox horizontalGap="1">
  60.                 <mx:Text text="label5" fontSize="10"/>
  61.                 <mx:Text text="0000000000000000000000000000000" fontSize="10"/>
  62.             </mx:HBox>
  63.         </local:FlowBox>       
  64.     </mx:Panel>
  65. </mx:Application>
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Reddit
  • Technorati
  • StumbleUpon
  • Twitter
RSS Enjoy this Post? Subscribe to Ntt.cc

RSS Feed   RSS Feed     Email Feed  Email Feed
You can leave a response, or trackback from your own site.

One Response to “a tip for Flexbox of Flexlib–How to re-layout the children when the width of FlowBox is set to 100%”

Leave a Reply