Static Main class - AS3
actionscript-3, flash, program-entry-point
Solution
There is not concept of static class in AS3.
You can use the singleton pattern to expose the unique instance of your main class :
public class Main extends Sprite {
public static var instance:Main;
public function Main() {
instance = this;
}
...or just mark expose other properties/methods as `static`, although it becomes harder to manage.
I need to mention though that using `static` sometimes leads to bad code design (instead, you can pass the instance of `Main` to classes that need it through their constructor for instance)
Problem
Is there a way to make the main class - the one based on the main .fla - static? so we could use it as in java, being able to reference it from other classes, because I have to pass the instance of the main itself as a parameter to a class, otherwise I loose reference. I tried to add static prefix but seems as3 doesn't allow it.