Please note that ExpatTech no longer operates regular office hours, meeting is by appointment only. Please call +36306031104 for details.

ExpatTech Techblog

Peter Todd 2010.08.03. 14:09

Flash Cookbook - Tricks - Global variables

Sometimes it's useful to use global variables. In AS3 it's quite easy: you create a class and add static variables to it.

package
{
    public class Vars
    {
        public static var value:int = 0;
    }
}

To reach it from anywhere import the class (import Vars;) if needed and done.

trace(Vars.value);
Vars.value= 10;
trace(Vars.value);

Output:

0

10

(reference tag: singleton)