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.
Is there a way to make the main class – the one based on
Share
There is not concept of static class in AS3.
You can use the singleton pattern to expose the unique instance of your main class :
…or just mark expose other properties/methods as
static, although it becomes harder to manage.I need to mention though that using
staticsometimes leads to bad code design (instead, you can pass the instance ofMainto classes that need it through their constructor for instance)