/ 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
// make a class called GlobalVars.as package com { public class GlobalVars { public static var vars:Object = {}; } } // then in your other classes import com.GlobalVars; GlobalVars.vars.whatever = "something to store" // then in any other class just do your import of com.GlobalVars, then: trace (GlobalVars.vars.whatever) // returns "something to store"
You need to login to post a comment.
