Static properties are properties bound to a class instance.  This is usually
the way I would do it.

you create a class login info as normal then inside you can put

public static var userId:String;

This can then be accessed anywhere in the application by LoginInfo.userId as
stated by Gordon. The benefit of this is if you want to put many things
accessable from anywhere in the application they would quickly polute your
applications namespace.

You could always create a User class in this way that has all three pieces
of information thats also creates the welcome message.

this would look something like this.  Note I don't have access to FB at the
moment so the syntax is from memory.  I know the package part is missing
there may be more mistakes.

public class User
{
  public static var _userId:String;
  public static var _password:String;
  public static var _role:Role;

  /**
   * Returns a message depending on the users userId and role.
   * Delegates to the role class for the role description
   * @returns A message to display to the user who has just logged in.
   * @see com.example.Role#description
   */
  public static function getWelcomeMessage():String
  {
    var welcomeText:String="Welcome ";
    welcomeText = welcomeText + _userId;
    welcomeText = welcomeText + " you are currently logged into the role ";
    welcomeText = welcomeText + _role.description;
    return welcomeText;
  }

}

On Fri, Aug 7, 2009 at 8:31 PM, spuy...@ymail.com <spuy...@gmail.com> wrote:

> Thanks Gordan.  Using the first option worked.  I am also interested in the
> second option but am not certain where to start.  Could you provide a little
> more detail?
>
> Thanks,
> Lee
>
>
> --- In flexcoders@yahoogroups.com, Gordon Smith <gosm...@...> 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: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
> Behalf Of spuy...@...
> > Sent: Wednesday, August 05, 2009 8:19 AM
> > To: flexcoders@yahoogroups.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
> >
>
>
>
>
> ------------------------------------
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Alternative FAQ location:
> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> Links
>
>
>
>

Reply via email to