Another way to do this would be to make "username" and "password" public properties on the pop-up. Use either public vars or getter/setter functions.
Then, in the loginHandler function, you can do: var loginPopUp:LoginPopup = event.target as LoginPopup; var username:String = loginPopUp.username; //Flexbuilder will code hint this property if you do the var like above var password = loginPopUp.password; Tracy Spratt, Lariat Services, development services available _____ From: [email protected] [mailto:[email protected]] On Behalf Of Gordon Smith Sent: Friday, August 07, 2009 2:48 PM To: [email protected] Subject: RE: [flexcoders] Re: How to make variables persist across application The simplest way to use custom events is to use the mx.events.DynamicEvent class. When the application creates the LoginPopup component, have it listen for "login" events like this: var loginPopup:LoginPopup = new LoginPopup(); loginPopup.addEventListener("login", loginHandler); PopUpManager.showPopup(loginPopup); Have your LoginPopup class dispatch a "login" event when it closes: var loginEvent:DynamicEvent = new DynamicEvent("login"); loginEvent.username = usernameTextInput.text; loginEvent.passwrod = passwordTextInput.text; dispatchEvent(loginEvent); Have you application handle the "login" event like this: private function loginHandler(event:DynamicEvent):void { // do something with event.username and event.password } If you want to be more formal and "type-safe", you would declare an AS subclass of Event instead of using DynamicEvent, but that's another lesson. Gordon Smith Adobe Flex SDK Team From: [email protected] [mailto:[email protected]] On Behalf Of [email protected] Sent: Friday, August 07, 2009 11:36 AM To: [email protected] Subject: [flexcoders] Re: How to make variables persist across application Thanks. I am not even certain what you mean by dispatching a custom event. I have heard of Shared Objects though. Can you point me to a goo resource on how to do this? Thanks, Lee --- In flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com, "valdhor" <valdhorli...@...> wrote: > > Or you could dispatch a custom event to your application that contains a user info object. > > Or you could save the user info data to a shared object. > > > --- In flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com, Gordon Smith <gosmith@> wrote: > > > > You have several options. Perhaps the simplest is to declare > > > > public var userid:String; > > > > in your Application. The login popup can then access this var as Application.application.userid and set it. > > > > Other possibilities include a LoginInfo class with static vars (so that any code can just access LoginInfo.userid) or a LoginInfo instance attached to your application (so that any code can reference Application.application.loginInfo.userid). > > > > Gordon Smith > > Adobe Flex SDK Team > > > > From: flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com [mailto:flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com] On Behalf Of spuyear@ > > Sent: Wednesday, August 05, 2009 8:19 AM > > To: flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com > > Subject: [flexcoders] How to make variables persist across application > > > > > > > > Is there a way to have the variables I set in a pop-up window (think login), persist and be accessible even when that pop-up is closed? > > > > For example, I have an application that uses a pop-up login window to control access to the application. The user supplies userid, password and role. When the user is authenticated, the pop-up closes and a viewstack is displayed based on the results of the role selected in the pop-up. > > > > All that works just fine. Now, I want to display the userid in the components within the viewstack. For example I want to display a welcome message based on the userid. > > > > I cant seem to figure out how to do this. Any help would be appreciated. > > > > lee > > >

