这与您的第一个问题有点不同。
视图类不能直接访问模型类,因此视图类必须调度一个事件来改变模型类。
1.)您必须定义某种新事件
public class ViewPropIsChangedEvent extends Event
{
public static const SET_NEW_VALUE:String = "theNewValue";
private var _value:Object;
public ViewPropIsChangedEvent(type:String, value:Object, bubbling:Boolean=true, cancelable:Boolean=false)
{
super(type,bubbling,cancelable);
_value = value;
}
public function get value():Object
{
return _value;
}
}
2.) 当您更改 View.mxml 中的 ViewProp 时,您必须调度一个事件
dispatchEvent(new ViewPropIsChangedEvent(ViewPropIsChangedEvent.SET_NEW_VALUE, theNewValue))
3.) 在 EventMap 中你必须处理事件
</EventHandlers type="{ViewPropIsChangedEvent.SET_NEW_VALUE}">
<PropertySetter generator="{ClassManager}"
targetKey="ClassProp"
source="{event.value}"/>
</EventHandlers>
4.) 在 ModelMap 中,您必须已经将 Secondview.SecondProp 绑定到 ClassManager.ClassProp
<Injectors target="{Secondview}">
<PropertyInjector targetKey="SecondProp"
source="{ClassManager}"
sourceKey="ClassProp"/>
</Injectors>