In this example, the ‘data’ property is an Object. Properties assigned to
Objects are not bindable. There should have been warnings in the compile
output or in the console at runtime.
If you know the set of properties on the data object, you should define a
class for that.
[Bindable]
public class MyModelDataSubObject
{
public var propOnData:String;
}
And:
[Bindable]
public class ModelLocator extends EventDispatcher implements IModelLocator
{
private static var _instance:ModelLocator;
public var data:MyModelDataSubObject;
public function ModelLocator(enforcer:SingletonEnforcer)
..
-Alex
On 11/13/14, 12:49 PM, "mark goldin" <[email protected]> wrote:
>Something like this. A bit simplified:
>package
>{
>
>[Bindable]
>public class ModelLocator extends EventDispatcher implements IModelLocator
>{
>private static var _instance:ModelLocator;
>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{}
>
>
>On Thu, Nov 13, 2014 at 2:44 PM, Alex Harui <[email protected]> wrote:
>
>> Declaring a class [Bindable] does not make its sub-objects bindable.
>>Show
>> us the code for the model’s data property.
>>
>> -Alex
>>
>> On 11/13/14, 12:31 PM, "mark goldin" <[email protected]> wrote:
>>
>> >It's an object. The whole model class is Bindable.
>> >
>> >On Thu, Nov 13, 2014 at 2:11 PM, Alex Harui <[email protected]> wrote:
>> >
>> >> It appears you are binding to sub-objects in the model, and they may
>>not
>> >> be bindable. What is _model.data?
>> >>
>> >> -Alex
>> >>
>> >> On 11/13/14, 10:49 AM, "mark goldin" <[email protected]> wrote:
>> >>
>> >> >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
>> >> >>
>> >> >>
>> >>
>> >>
>>
>>