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

    LayoutBase.getElementBounds() = 0 in updateDisplayList()


      Hi !


      Here is my situation, i have a simple skin which have a border which contains a datagroup:



          <s:BorderContainer id="border" width="100%">
              <s:DataGroup clipAndEnableScrolling="true" id="clip"
                      <s:HorizontalLayout id="hl" gap="10" />



      On my component side i have a myDataProvider:IList properties which the clip.dataProvider is binded to. If i add something in myDataProvider then clip.dataProvider is updated.

      When I add something to myDataProvider, I have to wait for my clip to be larger than the border to be invalidated (i mean DisplayList). That's the first thing that bother me. But then, when I am inside of updateDisplayList() and i want to running through my clip elements, layout bounds are not yet set for the last elements:



      override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
          super.updateDisplayList(unscaledWidth, unscaledHeight);
          var i:int = 0;
          trace("clip.numElements:", clip.numElements);
          while (i < clip.numElements)
              var bound:Rectangle = hl.getElementBounds(i);
              trace("bound.right:" + bound.right,
                    "elt.width:", clip.getElementAt(i).getPreferredBoundsWidth());
              bound = hl.getElementBounds(i);



      This code could print for example:



      clip.numElements: 3
      bound.right:79 elt.width: 79
      bound.right:161 elt.width: 72
      bound.right:0 elt.width: 86



      I would like to have access not only the width, but also the position. What do i have to wait for to get those information ? I know i could do a trick with (preferred size + gap value) but i would prefer to avoid that.


      Thanks !