Search code examples
apache-flexstaticadobepublicviewstack

adobe flex static function reference control


Is it possible to reference a control in an application from a static function?

What I have is a Viewstack containing VBoxes stored in separate controls. Ex:

<mx:ViewStack id="content" width="100%" height="100%" resizeToContent="true">
    <controls:Login/>
    <controls:Dash/>            
    <controls:Input/>   
    <controls:Review/>
    <controls:Search/>  
</mx:ViewStack>     

Once I get logged in on my login control, I would like to change the selected index of my ViewStack. From my outside controls, I cannot reference my ViewStack by name. I can reference a public static function from an outside control however I cannot refer to the ViewStack from within that function. Any help is greatly appreciated.

JH


Solution

  • Normally you can have a singleton class where you can save the instance of the main application and if you view stack is resides inside your main application then you can do some thing like this

    public static function changeIndex(index:int):void
    {
        FlexGlobals.topLevelApplication.content.selectedIndex = index;
        //urappinstance.content.selectedIndex = index;
    }