+1
private static var _instance:ModelLocator;
public static function getInstance():ModelLocator
{
if(! _instance)
_instance = new ModelLocator();
return _instance;
}
Only creating new instance when one isn't present. Since it's static, it
should only be done once.
-Mark
-----Original Message-----
From: Harbs [mailto:[email protected]]
Sent: Friday, November 14, 2014 3:54 AM
To: [email protected]
Subject: Re: Singleton question
No. That’s wrong. It should be:
private static var _instance:ModelLocator;
public static function getInstance():ModelLocator
{
if(! _instance)
_instance = new ModelLocator();
return _instance;
}
(No else, and you need to assign _instance.)