No, they are not static. I even replaces public var ... with setter and
getter. Still the same.
Here more code for singleton:
public var data:Object;
public function ModelLocator(enforcer:SingletonEnforcer)
{
if (enforcer == null){
throw new Error("You can have only one ModelLocator");
}
}
 public static function getInstance():ModelLocator{
 if (_instance == null){
_instance = new ModelLocator(new SingletonEnforcer());
 }
 return _instance;
 }
class SingletonEnforcer{}


In another class I am getting an instance of singleton:
private var _model:ModelLocator = ModelLocator.getInstance();

BindingUtils.bindSetter(onDataLoaded, _Model.data, "propOnData");
new GetDataEvent().dispatch();

public function onDataLoaded(value:String):void
{
trace(2);
if (value)
{
......
}
}

this is a command that set to get data when GetDataEvent event is triggered:

public function result(data:Object):void
{
var re:ResultEvent = data as ResultEvent;
_assetHealthModel.data = re.result as Object;
trace(1);
}

In Console I see
2
1

but never 2 again.

Hope, it's clear.

Thanks


On Thu, Nov 13, 2014 at 12:37 PM, Alex Harui <[email protected]> wrote:

>
>
> On 11/13/14, 10:04 AM, "mark goldin" <[email protected]> wrote:
>
> >Here is singleton definition:
> >[Bindable]
> >public class ModelLocator extends EventDispatcher implements IModelLocator
> >
> >All properties on that class are public vars.
>
> I’ll assume you are trying to tell me that they are not public static vars?
>
> When we’ll need to know more about how the instance is shared, whether you
> are getting warnings and compile time or runtime, and probably more
> details about what the symptoms are.
>
> -Alex
>
>

Reply via email to