I need to create popup window with several forms. As it's popup I don't add it to any component - just create it with "new" operator. The problem is that all popup window's childern are null until I add window to some component. I found out that there is initialize() function that should create all window's children and it does but only childern that are not form's childern.
In exaple below saveButton and cancelButton will be created after window.initialize() but addPhotosButton not.
<s:Button id="addPhotosButton" />
<s:Button id="saveButton" />
<s:Button id="cancelButton" />
I need to have all window's children created without adding it but dunno how...
Could anyone help me, please?
Since you use MXML file for implementing your form, Flex compiler generates AS3 code which follows normal component lifecyle rules: that is all components are created in createChildren() method when you add the component to the display list. One way to get around this is to implement your form in pure AS3 and create all stuff in the constructor.
The better approach would be to create isntance of the component, add event listener for CREATION_COMPLETE (you could also use INITIALIZE) event, add your component to the display list. When you receive the event, it is safe to do whatever you need with that component and its children.
Your solution is good - I listen for a popup's creation complete event and when I receive it I do stuff I needed with popup's children.
But... there's still the question without answer: what is wrong with components inside form that they're not created - like components outside form - at popup.initialize() execution? As far as I know createChilden() function is executed by initialize() function and because form is one of initialized component's children then it should be created but is not.