Apache flex 效果标记内的绑定效果属性不起作用?
我们正在努力做到这一点:Apache flex 效果标记内的绑定效果属性不起作用?,apache-flex,binding,mxml,effects,Apache Flex,Binding,Mxml,Effects,我们正在努力做到这一点: <rollOverEffect> <AnimateProperty property="scaleX" toValue="{originalWidth + scaleFactor}" /> </rollOverEffect> 然而,似乎对值的影响总是NaN。如果我将该值设置为常量,则效果有效。这样的效果难道不能使用数据绑定吗 附录: 原始宽度和缩放因子都是可绑定的。通过将效果移出rollOverEffect标记,给它和
<rollOverEffect>
<AnimateProperty property="scaleX" toValue="{originalWidth + scaleFactor}" />
</rollOverEffect>
然而,似乎对值的影响总是NaN。如果我将该值设置为常量,则效果有效。这样的效果难道不能使用数据绑定吗
附录: 原始宽度和缩放因子都是可绑定的。通过将效果移出rollOverEffect标记,给它和id,然后像这样绑定到它,我成功地实现了这一点:
<AnimateProperty id="scaleEffect" property="scaleX" toValue="{originalWidth + scaleFactor}" />
<MyComponent rollOverEffect="{scaleEffect}" />
你知道为什么这行得通而前一个代码不行吗?后一个代码段创建了第二个不必要的绑定,虽然不可读,但至少可以工作
附录: 下面的代码强调了这个问题。无论滑块设置为什么,效果的angleTo属性的值将始终设置为滑块初始值设置为的任何值
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:VBox horizontalCenter="0" verticalCenter="0">
<mx:Label text="Rotation (mouse over on canvas triggers effect):" />
<mx:HSlider id="slider" width="200" minimum="0" maximum="360" value="90" />
<mx:Spacer height="50" />
<mx:Canvas borderStyle="solid" borderThickness="1" borderColor="#ff0000" backgroundColor="#0000ff" width="200" height="200">
<mx:rollOverEffect>
<mx:Rotate angleTo="{slider.value}" duration="500" />
</mx:rollOverEffect>
<mx:rollOutEffect>
<mx:Rotate angleTo="{-slider.value}" duration="500" />
</mx:rollOutEffect>
</mx:Canvas>
</mx:VBox>
</mx:Application>
将与实际生成预期结果的以下代码进行比较:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Rotate id="rollOver" angleTo="{slider.value}" duration="500" />
<mx:Rotate id="rollOut" angleTo="{-slider.value}" duration="500" />
<mx:VBox horizontalCenter="0" verticalCenter="0">
<mx:Label text="Rotation (mouse over on canvas triggers effect):" />
<mx:HSlider id="slider" width="200" minimum="0" maximum="360" value="90" />
<mx:Spacer height="50" />
<mx:Canvas rollOverEffect="{rollOver}" rollOutEffect="{rollOut}" borderStyle="solid" borderThickness="1" borderColor="#ff0000" backgroundColor="#0000ff" width="200" height="200" />
</mx:VBox>
</mx:Application>
所以本质上问题是,为什么在第一个例子中绑定不起作用?没有错误或警告告诉您,我在文档中也找不到任何与此相关的内容,这可能是一个bug吗?您需要向我们展示更多代码。你能试试下面的代码吗?这行吗
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<!-- Simple exemplo to demonstrate the AnimateProperty effect. -->
<mx:Sequence id="animateScaleXUpDown" >
<mx:AnimateProperty property="scaleX" fromValue="{ns.value}" toValue="{ns.minimum}" duration="1000" />
<mx:AnimateProperty property="scaleX" fromValue="1.5" toValue="1" duration="1000" />
</mx:Sequence>
<mx:Panel title="AnimateProperty Effect Example" width="75%" height="75%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<mx:Text width="100%" color="blue"
text="Click on the image to use the AnimateProperty effect with the scaleX property."/>
<mx:Image id="flex" source="http://stackoverflow.com/content/img/stackoverflow-logo.png"
mouseDownEffect="{animateScaleXUpDown}"/>
<mx:NumericStepper id="ns" width="62" value=".5" minimum="1" maximum="3" stepSize="0.5" enabled="true"/>
</mx:Panel>
</mx:Application>
是的,对不起。originalWidth和scaleFactor都是可绑定的。你能把一小段代码放在一起演示你的问题吗?很遗憾,我现在不得不离开办公室了,但我明天会创建一个小的演示应用程序来突出这个问题。是的,这些代码可以工作,我昨晚在附录中做了同样的事情。然而,最初的问题仍然适用,为什么在effect属性标记中实例化效果时绑定不起作用?稍后我将发布一些示例代码。