2 Replies Latest reply on Apr 14, 2008 12:11 PM by realtime158


    realtime158 Level 1

      Instead of using Cookies what i want to do in Flex is have a global variable that will be avaiable anywhere in the application. So when a user logs in the userID variable will have the value of 2 and can be accessed anywhere in the application is this possible?

        • 1. Re: variables
          ntsiii Level 3
          There are several ways to do this. The simplest is to create apublic variable in the main application scope(not in a function), use Application.application.myVar to reference that var. that reference will work from anywhere, including apps loaded using swfLoader. Import mx.core.Application into each component where you need that. I create a var in each component, _app:application, and assign it in an init function. Just saves some typing.

          Another way is to use a singleton data model class. It is a more flexible solution than global vars.

          • 2. Re: variables
            realtime158 Level 1
            Thanks for the help :)