Posted By

visualadvance on 02/07/10


Tagged

object globalvars


Versions (?)


Advertising

Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


AS3: GlobalVars Class File


Published in: ActionScript 3 






A little hack to store variables in a class file that all other classes can access.

VERY IMPORTANT: I have found an issue where, even if you have all your cross-domain issues resolved, the GlobalVars will be undefined if your swfs are cross-domain.

Expand | Embed | Plain Text
  1. // make a class called GlobalVars.as
  2. package com
  3. {
  4. public class GlobalVars
  5. {
  6. public static var vars:Object = {};
  7. }
  8. }
  9.  
  10. // then in your other classes
  11. import com.GlobalVars;
  12. GlobalVars.vars.whatever = "something to store"
  13.  
  14. // then in any other class just do your import of com.GlobalVars, then:
  15. trace (GlobalVars.vars.whatever) // returns "something to store"

Report this snippet 

You need to login to post a comment.

Download royalty free graphics