3 Replies Latest reply on Jul 5, 2009 9:59 AM by _Natasha_

    How to implement Singleton for a Subclass which calls super() of the Superclass?

    flexiom

       

       

      Given:

       

            public class HelloWorldService extends RemoteService

            {

                  private static var _instance:HelloWorldService;

                  private static var phpServiceClass:String="HelloWorld";

       

                  public function HelloWorldService(cid:String=null, cep:String=null)

                  {

                        if (_instance)

                              throw new Error("Error: " + this + " already exists.Use getInstance(); instead");

       

                        _instance=this;

                        //set channels Id and Endpoint – workaround for bug - http://bugs.adobe.com/jira/browse/ASC-3143 

                        if (!cid)

                              cid=SrvCfg.CHANNEL_ID;

                        if (!cep)

                              cep=SrvCfg.CHANNEL_ENDPOINT;

                        super(SrvCfg.SRV_ID, SrvCfg.SRV_DESTINATION, cid, cep);

                  }

       

                  public static function getInstance():HelloWorldService

                  {

                        if (!_instance)

                              _instance=new HelloWorldService();

                        return _instance;

                  }

      }

      On the line whicht calls the super() i’m getting the follovin Error

       

      1201: super-statement can not be called after useage of this-, super-, return- oder throw-statements (it is translation from german errormessage).

       

      How can i implement singleton implementieren and still be able to call super() of my superclass?

       

      tia