The UpdateManager.as script will help you to call a big amount of functions without the problems of creating many enter frame listeners. Also, it will help you to make pauses.
Note: This script needs a public static instance inside Main.as of Mono.as.
Initial set up UpdateManager.as
In order to use it, first, you will need a public static instance of Mono.as in your Main class. Once you have it, you will be able to use it without any problem. You can create a new var with an instance of UpdateManager.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.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(); } } }
Now you will be able to access it from anywhere by accessing mono first.
Adding and removing callbacks
If you want to call a function once per frame you will need to add the function by doing this:
Main.mono.updateManager.addCallBack(functionToCall);
And if you want to remove the function from that list, you will need to remove it by doing this:
Main.mono.updateManager.removeCallBack(functionToCall);
Take in mind you will be to do this from anywhere.
Public Functions
- addCallBack(call:function):void
- removeCallBack(call:function):void
Private Functions
- evUpdate(e:Event):void
Public Vars
- isPaused:Boolean
Private Vars
- _callBacks:Vector.<Function>