I have some custom components, that derived from UIComponent. I overloaded the updateDisplayList so they have custom look. I've created a layouter that lays out these custom components, but to place them correctly, I have to know the custom componets width, height. They are created dynamically. After all of them created (creationCompleted event fired for every), i try to laying out them, but width/height property is still 0.
I am also tried to add them to a canvas, before the layout process.
So my question is, how to create custom UIComponent that placed dynamically, and get to know the width and height of it.
thanks
edit:
With the use of the mx_internal namespace I can set width and height (using the internal $width and $height fields), and it looks like it is working. But not so clean/good solution.
If you're inheriting from UIComponent, rather than from one of its subclasses, you'll probably want to make sure you're implementing the measure() method, among others. Check out the Flex docs here for more information on implementing your own UIComponents -- there's a good bunch of info to read here, but it's all stuff you should probably know if you're deriving from UIComponent directly:
http://www.adobe.com/livedocs/flex/3/html/help.html?content=ascomponents_advanced_3.html
Hope it helps! You might also try posting a little code, just so we have something more specific to go on. But chances are, you're just not implementing something you should be in order to retrieve those values. (And your instinct is correct -- you shouldn't have to dig into mx_internal in order to get what you need.)
Maybe this works?
component.getExplicitOrMeasuredWidth()
component.getExplicitOrMeasuredHeight()