How to use the same variable in different scenes in AS3 Flash CS6?

advertisements

I have thisvar num:Number; in Scene 1. I want to use it in the Scene 2 but I have no idea how to do it.

Sorry I am a newb and I have no idea how to look at the documentation corrrectly.

Please help.

Thanks


One of the possible solutions would be to declare a class that would contain a static variable.

public class StaticVars {
    public static var num:Number=0;
    public function StaticVars() {}
}

Then you address it from anywhere using StaticVars.num. You can fit as many variables in a single class like this as you need to.