4 Replies Latest reply on Feb 13, 2011 11:06 AM by Shongrunden

    Simple Layout Question


      Hi Gang,



      var theLayout:string = "Horizontal"; 







           <s:BasicLayout id="Single"/>

           <s:HorizontalLayout id="Horizontal" gap="5" variableColumnWidth="true"/>

           <s:VerticalLayout id="Verticle" gap="5" variableRowHeight="true"/>

           <s:TileLayout id="Tiled"/>






      how to I pass "theLayout" value into my DataGroup



      <s:DataGroup  id="ProductsDataGroup" layout = {theLayout} ...??





        • 1. Re: Simple Layout Question
          Flex harUI Adobe Employee

          You can't pass a string.


          var theLayout:LayoutBase = new HorizontalLayout;  

          • 2. Re: Simple Layout Question
            Andrei Kouzmenkov

            In Spark what you need to pass is an instance of one of Layout objects, not a string.


            For examples see Adobe doc, e.g.:


            • 3. Re: Simple Layout Question
              mr_payne Level 1

              Thanks gang..!


              So is it possible to change the layout on the fly...


              my original attempt is to make



              public var someLayout = "Horizontal";




              and then go



              someLayout = "Tiled";





              someLayout = "Verticle";

              • 4. Re: Simple Layout Question
                Shongrunden Adobe Employee

                As mentioned earlier you have to work with objects not strings.   Here is an example of what I believe is what you are trying to do:


                <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"





                            import spark.layouts.supportClasses.LayoutBase;


                            [Bindable] private var someLayout:LayoutBase;




                        <s:HorizontalLayout id="horizontalLayout" />

                        <s:VerticalLayout id="verticalLayout" />

                        <s:TileLayout id="tileLayout" />




                        <s:Button label="change layout to horizontal" click="someLayout = horizontalLayout" />

                        <s:Button label="change layout to vertical" click="someLayout = verticalLayout" />



                    <s:DataGroup layout="{someLayout}" itemRenderer="spark.skins.spark.DefaultItemRenderer">