6 Replies Latest reply on Jun 12, 2010 4:24 PM by jfb00

    Make Application resizeTocontent ?

    fagagou

      Hy,

       

      i coded an air app in flex, and i would like that the application's height is the same that their content. I applied this to Application tag but it doesn't work: verticalScrollPolicy="off"

       

      This is my code:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"                
                      usePreloader="false"
                      mouseDown="stage.nativeWindow.startMove()"
                      layout="absolute"
                      width="304"
                      verticalScrollPolicy="off"
                      alpha="1"
                      creationComplete="init()">
      
      
          <mx:Accordion id="accordion"  openDuration="200" borderSkin="{null}" verticalGap="7" resizeToContent="false">
                  <!-- Define each panel using a VBox container. -->
                      
                  </mx:VBox>
                  <mx:VBox label="Quoi de neuf ?"  verticalScrollPolicy="off">
                      <mx:Text htmlText="xxddddd" />
                  </mx:VBox>
                  <mx:VBox label="Le rappel du jour"  verticalScrollPolicy="off" >
                      <mx:Text htmlText="xx" />
                  </mx:VBox>
      
                  <mx:VBox label="Les promotions de la boutique"  verticalScrollPolicy="off">
                      <mx:Text htmlText="xx" />
                  </mx:VBox>
           </mx:Accordion>
      
      
      
      
      </mx:Application>
      
        • 1. Re: Make Application resizeTocontent ?
          jfb00 Level 3

          I don't understand like others

          What are you trying to do?

          If you want to fix you app height and the accordion to have the same size then you need to fix the height in your app and in your accordion you need to set the height to 100%.

          Let me know if that helps.

          Rgds

           

          Johnny

          • 2. Re: Make Application resizeTocontent ?
            fagagou Level 1

            Sorry, i will try to be clear as possible.

             

            I have an adobe air app, it contains an Accordion. So the height of the Accordion  is variable, it changes according wich Accordion's item is opened. I would like that the height of the Application is always the same that the height of the Accordion.

             

            thanks you for your help

            • 3. Re: Make Application resizeTocontent ?
              jfb00 Level 3

              Got it...

              Here is the free example, let me know if you have questions.

              Regards

               

              Johnny

               

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                              layout="absolute" minWidth="400" minHeight="300" backgroundColor="white">
                  <mx:Script>
                      <![CDATA[
                          private function getHeight():void{
                              var temHeight:Number = acc01.height;
                              this.height = temHeight;
                          }
                      ]]>
                  </mx:Script>
                  <mx:Accordion id="acc01" x="0" y="0" resizeToContent="true" updateComplete="getHeight()">
                      <mx:VBox label="Accordion Pane 1" width="100%" height="100%">
                          <mx:Button x="10" y="10" label="Button"/>
                          <mx:AdvancedDataGrid x="10" y="40" id="adg1" designViewDataType="tree">
                              <mx:columns>
                                  <mx:AdvancedDataGridColumn headerText="Column 1" dataField="col1"/>
                                  <mx:AdvancedDataGridColumn headerText="Column 2" dataField="col2"/>
                                  <mx:AdvancedDataGridColumn headerText="Column 3" dataField="col3"/>
                              </mx:columns>
                          </mx:AdvancedDataGrid>
                      </mx:VBox>
                      <mx:VBox label="Panel 2" width="100%" height="100%">
                      </mx:VBox>
                      <mx:VBox label="Panel 3" width="100%" height="100%">
                      </mx:VBox>
                      <mx:VBox label="Panel 4" width="100%" height="100%">
                      </mx:VBox>
                  </mx:Accordion>
              </mx:Application>

              1 person found this helpful
              • 4. Re: Make Application resizeTocontent ?
                fagagou Level 1

                Hy,

                 

                thanks for your code, it helped me and i improved the resize by adding an effect. But i have not what i want yet

                Is it possible to resize the application at the same moment when the Accordion size change, to make effect resize og the last one  synchronised with resize of Application.

                 

                In my code, inspired by yours, the Application is resized after the resize of Accordion is completed

                 

                <?xml version="1.0" encoding="utf-8"?>
                <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                                layout="absolute" minWidth="400" minHeight="300" backgroundColor="white" horizontalScrollPolicy="off" verticalScrollPolicy="off" mouseDown="stage.nativeWindow.startMove()">
                
                
                
                    <mx:Resize id="expand" target="{application}" heightTo="{acc01.height}"/>
                    <mx:Accordion id="acc01" x="0" y="0" resizeToContent="true" resize="expand.play();" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                        <mx:VBox label="Accordion Pane 1" width="100%" height="100%">            
                            <mx:Label text="hello"/>
                            <mx:Label text="hello"/>
                            <mx:Label text="hello"/>
                            <mx:Label text="hello"/>
                        </mx:VBox>
                        <mx:VBox label="Panel 2" width="100%" height="100%">
                            <mx:Label text="hello"/>
                            <mx:Label text="hello"/>
                        </mx:VBox>
                        <mx:VBox label="Panel 3" width="100%" height="100%">
                               <mx:Label text="hello"/>
                            <mx:Label text="hello"/>
                        </mx:VBox>
                        <mx:VBox label="Panel 4" width="100%" height="100%">
                               <mx:Label text="hello"/>
                            <mx:Label text="hello"/>
                        </mx:VBox>
                    </mx:Accordion>
                </mx:Application>
                

                • 5. Re: Make Application resizeTocontent ?
                  fagagou Level 1

                  up up ! Please help

                  • 6. Re: Make Application resizeTocontent ?
                    jfb00 Level 3

                    Well, you need to know the size already before you do the resize. If you know the size then apply the size by function for both app and accordion.

                    Here is another example that may help you out.

                    http://blog.flexexamples.com/2008/04/06/centering-a-pop-up-window-when-a-flex-application- is-resized/

                    Good luck

                     

                    Johnny