The code below demonstrates a mechanism for creating a singleton class in Actionscript. The DebugPanel is only accessible via DebugPanel.instance, which ensures that one and only one instance are ever created. It uses the fact that the Singleton class cannot be accessed outside the DebugPanel scope, preventing anyone from calling the DebugPanel constructor, to enforce this.
Note that this is not a typechecked approach, so it throws runtime rather than compile time errors. There definitely may be better mechanisms for implementing this structure. Whether or not singletons are a good idea is also up to you. I think the places where they won’t come back to bite you in the ass are limited in number, but definitely exist.
package com.rocketshipgames.core { public class DebugPanel { private static const _instance:DebugPanel = new DebugPanel(Singleton); public function DebugPanel(lock:Class) { if (lock != Singleton) { throw new Error("Invalid DebugPanel singleton instantiation."); } } public static function get instance():DebugPanel { return _instance; } // end DebugPanel } // end com.rocketshipgames.core } class Singleton { // end Singleton }