3 Replies Latest reply on Jan 9, 2014 8:28 PM by Flex harUI

    Help with creating a component: auto-sizing

    Aaron Beall Level 3

      I'm trying to create a lightweight component (extends UIComponent) that supports auto-sizing (aka default sizing.) Many of the Flex component's do this, for instance mx:Button will, if you do not set a size, size itself to be "large enough to hold the label text, and any icon." How can I do this with my component?

       

      I tried overriding measure() and setting the measured sizes (measuredWidth, measuredHeight, measuredMinWidth, measuredMinHeight) but updateDisplayList always gets called with values of 0, 0 for unscaledWidth and unscaledHeight, and the .width and .height properties always stay at 0, 0.

       

      I've looked over the mx:Button code quite a bit and cannot figure out how it manages to perform default/auto-sizing. Can anyone help?

       

      Cheers.

      -Aaron