I have a TabNavigator with NavigatorContent’s in MXML. Inside the first NavigatorContent I have a Group with an id="canvas"; I load a SWFLoader here. Inside the next NavigatorContent I have another Group with the id="sheetcanvas"; I want to load a SWFLoader here. The problem is that when I do that I get error #1009 null reference on the sheetcanvas id.
If I take that same group and put it anywhere else it works with no null reference!
The same error occurs when loading dynamically to a second group that exists in a second NavigatorContent of an Accordion, also. Am I doing something wrong or is there a bug?
<mx:TabNavigator id="tabs" width="650" height="100%">
<s:NavigatorContent width="100%" height="100%" label="Tab 1">
<mx:DividedBox top="3" bottom="3" right="3" left="3" direction="vertical" width="100%" height="100%">
<s:BorderContainer x="28" y="10" width="100%" height="100%">
<s:TextArea y="6" width="120" height="24" borderVisible="false"
text="{selectedNode.@label}"/>
<s:CheckBox y="6" right="10" label="Show Grid" selected="true"/>
<s:Scroller x="8" y="30" width="99%" height="90%" horizontalCenter="0">
<s:Group>
<s:Group id="canvas"/>
</s:Group>
</s:Scroller>
</s:BorderContainer>
<flexmd:FileEditor id="edit" width="100%" height="100%"
enablePrint="true" enableSyntaxColoring="true" savePhp="/FileEditor/php/save.php"
staticDemo="false"
chromeColor="0xDCDCDC"
/>
</mx:DividedBox>
</s:NavigatorContent>
<s:NavigatorContent width="100%" height="100%" label="Tab 2">
<mx:DividedBox top="3" bottom="3" right="3" left="3" direction="vertical" width="100%" height="100%">
<s:BorderContainer x="28" y="10" width="100%" height="325">
<s:Scroller x="8" y="30" width="99%" height="100%" horizontalCenter="0">
<s:Group>
<s:Group id="scanvas"/>
</s:Group>
</s:Scroller>
</s:BorderContainer>
</mx:DividedBox>
</s:NavigatorContent>
</mx:TabNavigator>
It’s not a bug. Some containers (like
TabNavigatororViewStack) don’t initialize their child-elements until they are shown. If you need to have access to (hidden) child-elements right from the start, set thecreationPolicyproperty toall.Eg.
<mx:TabNavigator id="tabs" width="650" height="100%" creationPolicy="all">Here’s some more information about creationPolicy.