Spark effects: why is procedural code preferred ov

2019-01-29 01:15发布

In Flex 3, MX effects could be triggered like this:

<mx:Resize id="myEffect" />
<mx:Button mouseDownEffect="{myEffect}" />

In Flex 4, Spark effects are triggered like this:

protected function onClick(event:MouseEvent):void {
    resizeEffect.end();
    resizeEffect.play();
}
...
<s:Resize id="resize" />
...
<s:Button click="onClick(event)" />

What was the reason to use this less declarative and longer approach? I couldn't find the answer anywhere in the docs.

(Two things to note:

  1. There might be small differences between mouseDown trigger and the click event, please ignore that, it's just an example.
  2. I'm not sure whether triggers would or would not work reliably for Spark effects. Maybe they would but I guess there is a reason why this possibility is not even mentioned in the official docs.

)

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-29 01:30

I'll add that the Flex 4 button still has effect triggers documented in the ASDocs, including a mouseDownEffect. Are you sure they don't work?

That said, behind the scenes, in the component's code, effect triggers work the same way as your second sample. Some code somewhere to get the effect, if it exists, and manually deal with the effect's playback.

Since Spark has a half baked component set, it is possibly such things were not implemented yet. It is also possible that the effect is not being passed to your button skin class which, I suspect, should probably be dealing with such visual changes.

Perhaps you should provide us with some runnable samples?

查看更多
Evening l夕情丶
3楼-- · 2019-01-29 01:44

Effect triggers are not officially supported in spark in the current release. You can track the progress of this feature here: http://bugs.adobe.com/jira/browse/SDK-19743

查看更多
登录 后发表回答