Return-Path: X-Original-To: apmail-flex-users-archive@www.apache.org Delivered-To: apmail-flex-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 19D0110F13 for ; Fri, 14 Nov 2014 06:49:28 +0000 (UTC) Received: (qmail 16895 invoked by uid 500); 14 Nov 2014 06:49:27 -0000 Delivered-To: apmail-flex-users-archive@flex.apache.org Received: (qmail 16867 invoked by uid 500); 14 Nov 2014 06:49:27 -0000 Mailing-List: contact users-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@flex.apache.org Delivered-To: mailing list users@flex.apache.org Delivered-To: moderator for users@flex.apache.org Received: (qmail 71845 invoked by uid 99); 14 Nov 2014 05:28:03 -0000 X-ASF-Spam-Status: No, hits=2.3 required=5.0 tests=SPF_SOFTFAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: softfail (athena.apache.org: transitioning domain of prashakumar@gmail.com does not designate 162.253.133.43 as permitted sender) Date: Thu, 13 Nov 2014 21:22:16 -0800 (PST) From: "pkumar.flex" To: users@flex.apache.org Message-ID: In-Reply-To: References: Subject: Re: Singleton question MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 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 > > . > 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.