Steven
Steven

Reputation: 71

How to open a new component with button, FLEX

I've made a login form which is working perfectly. However, when I enter my credentials and I want to click on the login button, I want to open a new window (or component). Can someone help me?

What kind of statement should I add to my click handlers of my login button? (component to proceed is called: feeds.mxml)

Thanks in advance

Upvotes: 0

Views: 318

Answers (2)

User
User

Reputation: 303

The cleanest way is usually to use a ViewStack. Depending on your requirements you may also be interested in using a TabNavigator or just a custom component as the "authenticatedView" of your primary ViewStack.

Fx 3 example:

    <mx:ViewStack id="viewStack">

        <mx:Canvas id="nonAuthenticatedView"/>
            //Your login screen "stuff" can go here.
            //On a successful login: viewStack.selectedIndex = 1.
            //On logout set selectedIndex to 0 to return to the login screen.
        </mx:Canvas>

        <mx:Canvas id="authenticatedView">
            //Instead of a Canvas this could be whatever, another ViewStack, TabNavigator, custom component, etc.
        </mx:Canvas>

    </mx:ViewStack>

This can get a lot more sophisticated if you start using a singleton model, bindings, and so on, but this should get you started.

Upvotes: 0

Pete TNT
Pete TNT

Reputation: 8403

Look into the concept of ViewStack navigation containers, which handles pretty much what you want. You could also use PopUpManager to pop it open depending on your feeds.mxml class.

Upvotes: 1

Related Questions