createChildren Called Before Component's MXML Bracket Logic Is Evaluated
- by Nalandial
I have the following MXML:
<mx:Script>
    var someBoolean:Boolean = determineSomeCondition();
</mx:Script>
....
<foo:MyComponent somePropertyExpectingIDataRenderer="{
                                    someBoolean
                                    ? new Component1ThatImplementsIDataRenderer()
                                    : new Component2ThatImplementsIDataRenderer()
                                                     }">        
</foo:MyComponent>
I have also overridden the createChildren() function:
override protected function createChildren():void {
    super.createChildren();
    //do something with somePropertyExpectingIDataRenderer
}
My problem is: createChildren() is being called before the squiggly bracket logic is being evaluated, so in createChildren(), somePropertyExpectingIDataRenderer is null.
However if I pass the component via MXML like this:
<foo:MyComponent>
    <bar:somePropertyExpectingIDataRenderer>
        <baz:Component1ThatImplementsIDataRenderer/>
    </bar:somePropertyExpectingIDataRenderer>
</foo:MyComponent>
Then when createChildren() is called, that same property isn't null.  Is this supposed to happen and if so, what other workarounds should I consider?