In my application I have a viewstack which I am changing via actionscript using the selectedChild attribute. The problem I run into is that I want to call a method in the component that is now the selected child in the viewstack, right after I assign it to be the child it gives me a "Cannot access a property or method of a null object reference." Is there some way that I can make this work without changing the creationPolicy to all?
Actionscript:
public function displayTaskDashboard(evt:Event):void
{
pm_viewstack.selectedChild = nc_taskDashboard;
taskDashboard.populateTasks(Globals.currentProject.Project_ID);
}
MXML:
<mx:ViewStack id="pm_viewstack" creationPolicy="auto">
<s:NavigatorContent id="nc_projectDashboard">
<components:ProjectDashboard/>
</s:NavigatorContent>
<s:NavigatorContent id="nc_taskDashboard">
<components:TaskDashboard id="taskDashboard" />
</s:NavigatorContent>
<s:NavigatorContent id="nc_taskWizard">
<components:TaskWizard id="taskWizard" />
</s:NavigatorContent>
</mx:ViewStack>
Try to call .validateNow() or .validateDisplayList() method on your ViewStack instance (pm_viewstack.validateNow() or pm_viewstack.validateDisplayList()) before accesing its child. But I'm not sure if it would help with child creation policy.