Do I need to create all objects which i will possible use with itemRenderer in createChildren function, even 开发者_运维问答if the current item must not show some of them ?
createChildren()
is for creating child components which lives along all host component's life-cycle. These children and their count are immutable like label of a button or border of a border container.
To create or remove dynamic children it is better to use commitProperies()
or updateDisplayList()
. The latter is more preferable because of you can create/remove dynamic children and perform their positioning in a single piece of code.
Short answer: no. You can create child objects whenever you'd like
Long answer: It is always best to work within the framework you're currently using. Flex has a method invalidateChildren (or something like that). You should consider calling that before you need to display your new objects and then build the new objects in the next call to createChildren.
Of course, sometimes situations call for deviation, but I have no way of knowing if this is one of those times.
精彩评论