Adobe Dreamweaver Forums



Last 10 THreads :         flash loader reappears after movie plays (Last Post : lyshamo - Replies : 3 - Views : 4 )           »          cfimage error (Last Post : -==cfSearching==- - Replies : 1 - Views : 2 )           »          How to turn IMAGE into MOVIECLIP??? (Last Post : Snufferson - Replies : 7 - Views : 8 )           »          Embed files in a projector (Last Post : ytlevine - Replies : 0 - Views : 1 )           »          ColdFusion = "old technology" (Last Post : Ian Skinner - Replies : 7 - Views : 8 )           »          Load dynamic text into an embeded swf (Last Post : mikeyjray - Replies : 4 - Views : 9 )           »          Log email text (Last Post : Torgom - Replies : 0 - Views : 1 )           »          Properties > Flex Build Path (Last Post : kevxross - Replies : 0 - Views : 1 )           »          Can Anyone Help With Sub Menus (Last Post : Murray *ACE* - Replies : 8 - Views : 9 )           »          transferring DW license from crashed computer (Last Post : Sonjay - Replies : 1 - Views : 7 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 11-21-2008, 08:13 PM
jfb00
 
Posts: n/a
Diggs:
Default Global variables

Hi All,
My app have a login page, after validate my login I want to stored the userid
in a global variable so I can use it alone all the app in flex.
Can I do global variables?
How can I do this?
In the pass I was able to do using session variables.
thanks

JFB




Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-21-2008, 09:42 PM
*gsb*
 
Posts: n/a
Diggs:
Default Re: Global variables

Global variables as in AS2 do not exist in AS3.
Global variables are usually a bad idea from a design point of view.

However the easiest way to do what you want is to define your username or
authorization variable on the main application object. Then anywhere in your
code you can access it via:

Application.application.yourAuthorizationVariable

Be sure to include where appropriate:
import mx.core.Application




Reply With Quote
  #3 (permalink)  
Old 11-21-2008, 09:53 PM
myIP
 
Posts: n/a
Diggs:
Default Re: Global variables

[I agree mostly with what gsb has posted. However I personally don?t like to
have any object accessing a variable somewhere in the application. ]

I don?t see why you would need to have a global variable in a Flex
application. If you need to simply store the user id, you should do this in
your model (that?s if you have one). If there is no model in your application
then I would create a singleton class perhaps called ?SessionModel?. And in
this class you can have a getter/setter to store the user?s id. Then this can
be accessed by any object in your application. However, as always you
shouldn?t exploit this design pattern (Singleton) freely.

Descendants of a parent object shouldn?t be tapping into a singleton. They
should be accessing their parent object for that info. At least that is a
simple rule of mine and others.

Or are you talking about shared objects? Which retains data on the user?s
machine when the user returns to the application after it has been terminated?

Reply With Quote


  #4 (permalink)  
Old 11-22-2008, 12:25 AM
rtalton
 
Posts: n/a
Diggs:
Default Re: Global variables

Use a shared object which stores the login info.
Clear it out whenever a user opens the application, otherwise it will always show them as logged in when you check it.
Reply With Quote
  #5 (permalink)  
Old 11-26-2008, 08:53 PM
jfb00
 
Posts: n/a
Diggs:
Default Re: Global variables

Thanks everyone reply's.
Looks like i need a share object so the user can reuse the data later.
Anybody have an example of this?
What is the disadvantage to have main application object?
Rgds

JFB




Reply With Quote
  #6 (permalink)  
Old 11-26-2008, 09:32 PM
myIP
 
Posts: n/a
Diggs:
Default Re: Global variables

To simply put it, a disadvantage of assigning a variable in the application
object is that it will be terminated when the application terminates. The
advantage of having a shared object, is that a variable can be retrieved so
that the user doesn?t have to reenter their id (Assuming that the user hasn?t
cleared their browser cache). If you do choose to use shared objects, keep in
mind, then anyone using that browser can access the account of the user?s
shared object.

//Shared Objects in Help docs
http://livedocs.adobe.com/flex/3/htm...nt=lsos_1.html


Reply With Quote


Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 11:29 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk