i have a class name sample_1.as
package {
import flash.display.MovieClip;
public class sample_1 extends MovieClip {
public var targetScene:String;
public function sample_1() {
// constructor code
}
}
}
and i want to access and change the targetScene string from different frames and also inside movieclips like
gotoAndPlay(targetScene);
or
targetScene = "MainMenuEnter";
how can i do that?
A quick and easy way to have a variable like that available from any frame/class is to make it static:
You can access
targetScenefrom anywhere usingsample_1.targetScene, for example:It’s not the best method to use, especially as a project gets bigger and has more components, declaring variables static for the sake of global access can lead to a lot of spaghetti code but it’s a quick ‘n’ dirty fix to get you started.