A Flex component's updateDisplayList() method is supposed to position and size any of the child objects that the component uses. It is also where you can do any programatic drawing that your component may require. With this in mind, here's a short list of things you should not be doing in updateDisplayList():
- Do not set the width or height properties of a child component, instead use the child component's
setActualSize()method to set it's width and height. - Do not set the x or y coordinates of a child component, instead use the child component's
move()method to specify it's x/y position. - Try to avoid calling
setStyle()or setting other properties on child components (that's whatcreateChildren()andcommitProperties()are for)
setActualSize() and move() do their jobs w/out invalidating the child component. 99% of the time there's no noticeable difference, except you have just caused the child component to execute a bunch of extra code because you invalidated the child component's size, properties, or displayList.
Along the same lines, you should try to avoid setting properties or styles on child objects in updateDisplayList(). This will also invalidate the child component. I've found myself wanting to set a style in updateDisplayList(), so I'm not saying you shouldn't do it ... just be aware of what you're doing, maybe there is a better approach :)
Thanks for the useful post.
ReplyDelete