Don,

I currently use a similar method of authenticating my users in Flex and 
store user access information.
My method might not be the best, but it works well for my configuration. 
I am using modules and other components that check login information.
Here it is:
I store all user data in an object that is a singleton.
I instantiate this class in the main application on initialization and 
set the data once there is a valid login.  I then access this class in 
any of my modules, components, etc throughout the application.  I have 
no problem with the binding, so far.
When the class is instantiated, you always go after the data in a 
getInstance method for the users data.  Every component now sees the 
same exact reference data.

I use this method, because my Flex applications may be authenticated 
already in another Flex application or Web Form and I have an 
initialization process in each application that checks for 
authentication the same exact way.  I extended Application to 
authenticate a user.  The process checks for a valid user login.  If the 
user is logged in already, a call is made to populate the user data into 
the singleton.  If not, the application loads a login module. Once a 
valid login is accomplished, the user data is populated.

There are plenty of examples out there of using a singleton class if you 
do not have one.

Regards,
Tony

donvoltz wrote:
>
> What is the best way to make the data in a custom class globally
> accessible to a multi-component application?
>
> I have a custom component called userlogin that consists of a form and
> connects to a database. When a user correctly logs in, the database
> returns a number of fields of data that I then use to fill the
> properties of a custom class called User, this instantiation of User
> is called currentUser typed as User.
>
> Another component called menuBar is an application control bar that
> allows for various selections based on the users site access level
> (stored in the custom User class) as well as the user name to show who
> is currently logged in.
>
> The problem I am having is how do I access the data stored within this
> custom class? I have set the class itself to Bindable with a metatag
> and also set currentUser to bindable, however, the menuBar component
> does not recognize this.
>
> I am at a loss of how to access this data. I guess I could create a
> custom event dispatcher and send this class data with an event and
> listen for this event in the menuBar component, however, this does not
> seem like the best idea. In this way I would need to store twice as
> much data and consume more resources. Is there another way to use this
> custom class data?
>
> Thanks for any help
>
> Don
>
> _
> .
>
>  

Reply via email to