Skip to content

Instantly share code, notes, and snippets.

@bitforth
Created September 26, 2013 00:56
Show Gist options
  • Save bitforth/6708393 to your computer and use it in GitHub Desktop.
Save bitforth/6708393 to your computer and use it in GitHub Desktop.
Como implementar Singletons en AS3
package
{
import flash.display.Sprite;
public class Singleton
{
private static var _instancia:Singleton;
public function Singleton(pvd:ClasePrivada)
{
}// Constructor vacío.
public static function instanciar():Singleton
{
if (Singleton._instancia == null)
{
Singleton._instancia = new Singleton(new ClasePrivada());
trace("Objeto Singleton creado");
}
else
{
trace("Oops! Ya existe un objeto de esta clase");
}
return Singleton._instancia;
}
}
}
class ClasePrivada;
{
public function ClasePrivada()
{
}// Constructor vacío
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment