Flex警告数据绑定将无法检测到“布局”的分配

时间:2021-09-27 19:28:06

I got some code:

我得到了一些代码:

...
<fx:Declarations>
<s:Animate id="toRight"   target="{cp.layout}">
<s:SimpleMotionPath property="horizontalScrollPosition"                                     valueFrom="{cp.layout.horizontalScrollPosition}" valueTo="{cp.layout.horizontalScrollPosition+42}"/>
            </s:Animate>
</fx:Declarations>
....
....
<s:List id="cp" horizontalScrollPolicy="off"  itemRenderer="com.mRenderer" horizontalCenter="1" verticalCenter="1" change="changeEvt(event)" borderAlpha="0"  width="458" height="65"   initialize="initList();"  >

.....

.....

I use that animation for smoothing move with arrows in my List.

我使用该动画在我的列表中用箭头平滑移动。

But I got some warnings:

但是我得到了一些警告:

Data binding will not be able to detect assignments to "layout".

数据绑定将无法检测“布局”的分配。

I know layout not bindable in List. but its not custom class. How can I prevent that?

我知道List中的布局不可绑定。但它不是自定义类。我怎么能防止这种情况?

1 个解决方案

#1


1  

So you're using the Animate effect to animate the horizontalScrollPosition of the layout object? And I assume that is working correctly.

那么您是否正在使用Animate效果为布局对象的horizo​​ntalScrollPosition设置动画?我认为这是正常的。

The warning you get is triggered by this curly brace binding expression: target="{cp.layout}". The warning is telling you that the List control does not dispatch any binding events if it's layout property changes. So if something in your app changes the list's layout, your animation effect will stop working.

您获得的警告由此大括号绑定表达式触发:target =“{cp.layout}”。警告告诉您,如果布局属性发生更改,List控件不会调度任何绑定事件。因此,如果您的应用中的某些内容更改了列表的布局,您的动画效果将停止工作。

That's just a warning, and as long as you don't expect to change the layout, your code should work just fine.

这只是一个警告,只要您不希望更改布局,您的代码应该可以正常工作。

If you'd like to make the warning disappear, you have three options:

如果您想使警告消失,您有三种选择:

  • Update your compiler settings so that this warning does not get generated (bad idea)
  • 更新您的编译器设置,以便不会生成此警告(坏主意)
  • Instead of using a property that is not bindable in your curly brace expression, use a function call that returns the non-bindable property.
  • 不使用大括号表达式中不可绑定的属性,而是使用返回不可绑定属性的函数调用。
  • Use a "creationComplete" event handler to assign the target property of the animation
  • 使用“creationComplete”事件处理程序分配动画的目标属性

Example of using a function in a binding expression:

在绑定表达式中使用函数的示例:

<s:Animate target="{getAnimationTarget()}" />

private function getAnimationTarget():Object
{
    return cp.layout;
}

While the same problem can occur (if the list's layout changes, no event will be dispatched by the list to update the binding), the above syntax should prevent the warning from being generated. The Flex compiler doesn't generate this warning, by design, when the curly brace expression includes a function call.

虽然可能会出现同样的问题(如果列表的布局发生更改,列表不会调度任何事件来更新绑定),上述语法应该可以防止生成警告。当花括号表达式包含函数调用时,Flex编译器不会按设计生成此警告。

Example of using the "creationComplete" event of the List:

使用List的“creationComplete”事件的示例:

<s: List creationComplete="myFunction() />

private myFunction()
{
    toRight.target = cp.layout;
}

#1


1  

So you're using the Animate effect to animate the horizontalScrollPosition of the layout object? And I assume that is working correctly.

那么您是否正在使用Animate效果为布局对象的horizo​​ntalScrollPosition设置动画?我认为这是正常的。

The warning you get is triggered by this curly brace binding expression: target="{cp.layout}". The warning is telling you that the List control does not dispatch any binding events if it's layout property changes. So if something in your app changes the list's layout, your animation effect will stop working.

您获得的警告由此大括号绑定表达式触发:target =“{cp.layout}”。警告告诉您,如果布局属性发生更改,List控件不会调度任何绑定事件。因此,如果您的应用中的某些内容更改了列表的布局,您的动画效果将停止工作。

That's just a warning, and as long as you don't expect to change the layout, your code should work just fine.

这只是一个警告,只要您不希望更改布局,您的代码应该可以正常工作。

If you'd like to make the warning disappear, you have three options:

如果您想使警告消失,您有三种选择:

  • Update your compiler settings so that this warning does not get generated (bad idea)
  • 更新您的编译器设置,以便不会生成此警告(坏主意)
  • Instead of using a property that is not bindable in your curly brace expression, use a function call that returns the non-bindable property.
  • 不使用大括号表达式中不可绑定的属性,而是使用返回不可绑定属性的函数调用。
  • Use a "creationComplete" event handler to assign the target property of the animation
  • 使用“creationComplete”事件处理程序分配动画的目标属性

Example of using a function in a binding expression:

在绑定表达式中使用函数的示例:

<s:Animate target="{getAnimationTarget()}" />

private function getAnimationTarget():Object
{
    return cp.layout;
}

While the same problem can occur (if the list's layout changes, no event will be dispatched by the list to update the binding), the above syntax should prevent the warning from being generated. The Flex compiler doesn't generate this warning, by design, when the curly brace expression includes a function call.

虽然可能会出现同样的问题(如果列表的布局发生更改,列表不会调度任何事件来更新绑定),上述语法应该可以防止生成警告。当花括号表达式包含函数调用时,Flex编译器不会按设计生成此警告。

Example of using the "creationComplete" event of the List:

使用List的“creationComplete”事件的示例:

<s: List creationComplete="myFunction() />

private myFunction()
{
    toRight.target = cp.layout;
}