我确实提交了 线 这是(再次阅读)完全错误的表述。这实际上是我想知道的:

在使用MATE的FLEX应用程序中,假设我们有一个名为View.mxml的View.mxml,带有名为ViewProp的属性和一个名为ClassManager的类带有属性ClassProp。假设我们有另一个带有属性secondprop的称为secondview.mxml的视图。

是否可以以某种方式定义以下方式:每当ViewProp更改(在View.mxml中)时,ClassProp也会在ClassManager中更改,这反过来又反映了其在secondview.mxml中的更改,属性secondprop?!!

我希望这次能正确描述它!

提前致谢

有帮助吗?

解决方案

这与您的第一个问题有些不同。

视图类不得直接访问模型类,因此,视图类必须派遣事件以更改模型类。

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.)在事件图中,您必须处理事件

</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>

其他提示

怎么样:

当ViewProp或ClassProp更改时,此属性调度事件和EventListener将在secondview.mxml中添加以修改属性secondprop。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top