Can anyone suggest a move efficient rotation function which can be stopped on demand?
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 callLate开发者_C百科r 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!
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.
精彩评论