Az Expattech az ünnepek alatt (dec.24-jan.1.) zárva tart. Nyitás: 2024.január 2

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)