Flex: Call method after viewstack change

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>

Answers


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.


Need Your Help

Calendar sync with custom add account in android

android calendar sync

I want to add events in calendar, i am able to add account but i don`t know how to sync with calendar.

How to automatically preselect (not just set the value) billing_state dropdown list to be the same as shipping_state dropdown list

javascript javascript-events

I looked all over on google, I guess I just don't know what to search for because I'm looking to do something relatively simple. I try to only ask questions on here if I am not able to find answers

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.