谁能建议一个可以按需停止的移动高效旋转功能?
我有一个 mxml 饼图,我想在单击按钮之前缓慢旋转,但是单击时它需要立即停止(或至少相当快地停止),然后以淡入淡出的方式引入标注标签。
我已经尝试过使用计时器函数来实现此目的:
protected function group1_creationCompleteHandler(event:FlexEvent):void
{
var rt:Timer = new Timer(20,0);
rt.addEventListener(TimerEvent.TIMER, rtt);
rt.start()
}
private function rtt(event:TimerEvent):void
{
QPieSeries.startAngle -=1;
}
以及 callLater 变体,它给出(毫不奇怪)相同的效果:
protected function group1_creationCompleteHandler(event:FlexEvent):void
{
rtt();
}
private function rtt():void
{
QPieSeries.startAngle -=1;
callLater(rtt);
}
但是,我的问题是这两种实现此效果的方法的性能都很差,这是可以理解的大量事件被反复触发和接收。
我一直在尝试使用 varrotateVar:Rotate = new Rotate(QPieSeries) 方法,但是当我停止它时,问题就出现了,标签与段不匹配,而不应用 < code>QPieSeries.startAngle 方法,并且它有导致跳转等的习惯,并且在应用于任何类型的循环时通常会破坏事物。
我认为我真正想做的(嗯,因为它可能会导致一个可行的解决方案)是定时循环中的某种 QPieSeries.startAngle = 60
,并具有某种插值效果在?并在某种定义的时间段内匹配循环的时间段。
然而,这超出了我的范围,如果有人对此有任何建议/意见,我将非常感激。
谢谢!
I have an mxml pie chart, which I would like to rotate slowly prior to a button click, however on click it needs to stop immediately (or at least reasonably quickly) and then the callout labels are introduced with a fade.
I have experiemented with both a timer function to achieve this:
protected function group1_creationCompleteHandler(event:FlexEvent):void
{
var rt:Timer = new Timer(20,0);
rt.addEventListener(TimerEvent.TIMER, rtt);
rt.start()
}
private function rtt(event:TimerEvent):void
{
QPieSeries.startAngle -=1;
}
as well as a callLater variant, which gives (unsurprisingly) the same effect:
protected function group1_creationCompleteHandler(event:FlexEvent):void
{
rtt();
}
private function rtt():void
{
QPieSeries.startAngle -=1;
callLater(rtt);
}
However, my issue is that both these methods of acheiving this effect are very poor on performance, which is understandable with the large number of events repeatedly being fired and received.
I've been trying to use the var rotateVar:Rotate = new Rotate(QPieSeries)
approach, but the issue comes when I stop it, the labels don't match up to the segments without applying the QPieSeries.startAngle
method, and that has a habit of leading to jumps etc and generally wrecking things when applied in any sort of loop.
I think what I really want to do (well, in that it may lead to a viable solution), is some sort of QPieSeries.startAngle = 60
in a timed loop, with some sort of interpolate effect going on? And over some sort of defined time period to match the time period of the loop.
However this is beyond me, if anyone has anything to suggest/say on this I'd really appreciate it.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该考虑使用 Tweening 库,例如 TweenLite 或 Tweener。您可以使用这些随着时间的推移改变任何对象的任何参数,并且它们随时对所有动画使用单个帧/计时器循环。
You should consider using a Tweening library, like TweenLite or Tweener. You can mutate any parameter of any object over time using these, and they use a single frame/timer loop for all animations at any time.