Created
September 26, 2013 00:56
-
-
Save bitforth/6708393 to your computer and use it in GitHub Desktop.
Como implementar Singletons en AS3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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