• About WordPress
    • WordPress.org
    • Documentation
    • Learn WordPress
    • Support
    • Feedback
  • Log In
Skip to content

MonoFlauta

Indie Game Developer

Menu
  • Blog
  • Portfolio
    • Games
      • Happy Ghost Studio
      • Etermax
      • Silky Smooth Studio
      • Fun+Mono
    • Frameworks & Tools
      • Framework Goat
      • Twitch Mono Integration
      • Framework Mono
      • Narwhal Engine
    • Others
  • Store
  • About Me

Framework Mono – Managers/ScreenManager.as

The ScreenManager.as script, with the Screen.as script will help you to have a clear flow between screens.
Note: This script needs a public static instance inside Main.as of Mono.as and had already instanced UpdateManager.as


Initial set up ScreenManager.as

In order to use it, first, you will need a public static instance of Mono.as in your Main class. Then, you will need to create an instance of UpdateManager.as inside Mono.as. Once you have it, you will be able to use it without any problem. You can create a new var with an instance of ScreenManager.as or you can just the one that is inside Mono and will let you have access from anywhere. For example, in case you want to do the second option (recommended), you should do the following:

 package
{      
import Mono.Managers.ScreenManager;
import Mono.Managers.UpdateManager;
import Mono.Mono;

import flash.display.Sprite;
import flash.utils.Dictionary;
      
      public class Main extends Sprite
      {      
            public static var mono:Mono;
            
            public function Main()
            {
                  mono = new Mono(stage);
                  mono.updateManager = new UpdateManager();
                  mono.screenManager = new ScreenManager();
            }
      }
}

Now you will be able to access it from anywhere by accessing mono first.


Creating Screens

For each screen you want to create, you will need to create a new class that inherits from Screen.as class. Then you will be able to override functions and use it with the ScreenManager. For example, you can create the class Menu that will inherit from Screen:

 package
{
      import Mono.Managers.Complements.Screen;
      
      public class Menu extends Screen
      {
            public function Menu(name:String)
            {
                  super(name);
                  
                  //Initiliaze the screen
            }
            
            public override function update():void
            {
                  //Update the screen      
            }
            
            public override function exit():void
            {
                  //Close the screen
            }
      }
}

Then, as the comments say, in the constructor class you will be able to initialize the class. Then, the update will be called once per frame and for last the exit will be called when the screen is changed.


Registering screens

In order to start using the screens with the ScreenManager.as, you will have to register each screen. To register them, you will only need to have the class you want to register (that inherits from Screen) and a name to assign it as the index.

For example, we can register the last screen under the name of “The menu screen” by doing the following:

 Main.mono.screenManager.registerScreen("The menu screen", Menu);

This will work from anywhere.


Changing screens

If you want to change to another screen. You will only need to say which one (the name of the screen will be the one that you used when registering) and call this method:

 Main.mono.screenManager.loadScreen("The name of the screen to load");

The screen manager will change them by calling the needed methods.


Public Functions

  • registerScreen(name:String, scr:Class):void
  • loadScreen(name:String):void
  • closeScreen():void

Private Functions

  • evUpdate():void
  • evChange(s:ScreenEvent):void

Private Vars

  • _screens:Dictionary
  • _currentScreen:Screen

Powered by WordPress MonoFlauta 2026 | All Rights Reserved.

Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
  • Manage options
  • Manage services
  • Manage {vendor_count} vendors
  • Read more about these purposes
View preferences
  • {title}
  • {title}
  • {title}