flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "pkumar.flex" <prashaku...@gmail.com>
Subject Re: Singleton question
Date Fri, 14 Nov 2014 05:22:16 GMT
do not create model locator object after class declaration. Use below
 getInstance() to create model locator object.
like this:

private static var _instance:ModelLocator;
 public static function getInstance():ModelLocator
{
 if(! _instance)

}

On Fri, Nov 14, 2014 at 12:58 AM, mark goldin [via Apache Flex Users] <
ml-node+s2333346n8738h63@n4.nabble.com> wrote:

> Here is my singleton:
> [Bindable]
> public class ModelLocator extends EventDispatcher implements IModelLocator
> {
> private static var _instance:ModelLocator = new ModelLocator();
> public var test:String;
>
> public function ModelLocator()
> {
> if (_instance != null){
> throw new Error("You can have only one ModelLocator");
> }
> }
>  public static function getInstance():ModelLocator
> {
>  return _instance;
> }
>  }
> }
>
> When I am debugging I see that _instance is always different object when I
> get an instance of my singleton. Is that right?
>
> Thanks
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-flex-users.2333346.n4.nabble.com/Singleton-question-tp8738.html
>  To unsubscribe from Apache Flex Users, click here
> <http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1&code=cHJhc2hha3VtYXJAZ21haWwuY29tfDF8LTU0MTcyMzE2NA==>
> .
> NAML
> <http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
*Regards,*
Prashant Kumar* | *Mob.: +91 8408811225




--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Singleton-question-tp8738p8769.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Mime
View raw message