This content has been marked as final. Show 5 replies
Yes, this is always a gotcha at first. Flex containers (such as Canvas, Panel, etc.) can have only UIComponents as children, not just DisplayObject. The trick is that a UIComponent can have simple DisplayObjects as children, so you need to wrap your shape:
var temp: UIComponent = new UIComponent();
hmm... is this still better than adding a new Box() and setting the background color? The reason I tried Shape was because I wanted to use as light a component/object as possible.
Backgrounds and such are considered "chrome". In containers we add and position them via the rawChildren property.
For ease of use, I'd just go with a Box and set its background colour. Really, we're not talking about a huge memory/speed difference here.
Thanks for the advice...
I was actually converting code over from Flex 1.5 where there is a pretty big difference between calling a beginFill()/lineTo() method on a UIComponent and attaching a whole new Container/MovieClip. In Flex 1.5 the application was so slow I trimmed out every container/MovieClip I could.
If it's not such an issue in Flex 2.0 then I will go with the easier to read addChild(new Box()) method.
Flex harUI - I assume that you mean if I create a new UIComponent and then add a Shape for color, I am essentially doing the same thing that normal containers like Box (a UIComponent) do with their chrome instance (a Shape?).