2 Replies Latest reply on Apr 7, 2010 2:32 AM by K-kOo

    setting ActualSize doesnt do anything

    K-kOo Level 1

      Hello everybody.

       

      I have simple skin which is like this:

       

          <s:BorderContainer id="border" width="100%" minWidth="0">
              <s:DataGroup clipAndEnableScrolling="true" id="clip"
                           itemRenderer="spark.skins.spark.DefaultItemRenderer">
                  <s:layout>
                      <s:HorizontalLayout id="hl" gap="10" />
                  </s:layout>
              </s:DataGroup>
          </s:BorderContainer>
      

       

      A border and a group. Easy !

      With a couple buttons on my main app I can control what's inside of my "clip"'s dataProvider.

      What i would like to do is hiding elements of my group when there are more than a specific number (even if there is enough space). So in my components code, i wrote this:

       

      override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
      {
          super.updateDisplayList(unscaledWidth, unscaledHeight);
          
          if (clip.numElements > 3)
              clip.setActualSize(hl.getElementBounds(2).right, clip.height);
          else
              clip.setActualSize(clip.width, clip.height);
      }
      

       

      But the clip never gets truncated ! I can see all my items that i added to it.

      It's only when i resize my whole component from the main app (thanks to a slider value), that the clip size gets updated. As soon as i add or remove something from it, its width return to the regular one.

       

      What am i missing in the whole display process here ?

       

      Thanks !

        • 1. Re: setting ActualSize doesnt do anything
          TeotiGraphix Level 3

          Hi,

           

          For one thing since you are using the HorizontalLayout, calling setActualSize() on a visual element is getting trampled by the layouts own calculations. If you want widths and heights to stick when using these layouts you need to either set explicitWidth or width.

           

          The method setLayoutBoundsSize() is actually somewhat of a proxy for setActualSize(). The differenece between the two is the first takes postLayoutTransform into account and then calls setActualSize().

           

          The setActualSize() method does not set explicit widths or heights, that is why you can't get it to "stick". The layout just ends up using the preffered width and height again.

           

          Mike

           

          http://www.teotigraphix.com

          http://blog.teotigraphix.com

          1 person found this helpful
          • 2. Re: setting ActualSize doesnt do anything
            K-kOo Level 1

            I tried the explicitWidth:

             

            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
            {
                super.updateDisplayList(unscaledWidth, unscaledHeight);
                
                if (clip.numElements > 3)
                    clip.explicitWidth = hl.getElementBounds(2).right;
                else
                    clip.explicitWidth = NaN;
            }
            

             

            But the problem now is once the clip have an explicitWidth, my component's udl() never get called again. So it doesnt matter if i keep adding or removing elements, it will keep the same size