问题
How to programmatically set the spin of component SpinnerList (Flex mobile) so that it can spin for a few seconds and then stopped at selected index?
回答1:
private function scrollToIndex(index:int, animationDuration:int = 1000):void {
if ((index != -1) && (list.layout != null)) {
var spDelta:Point = list.dataGroup.layout.getScrollPositionDeltaToElement(index);
if ((spDelta != null) && (spDelta.y != 0)) {
var target:DataGroup = list.dataGroup;
var animation:AnimateProperty = new AnimateProperty(target);
animation.property = "verticalScrollPosition";
animation.duration = animationDuration;
animation.toValue = target.verticalScrollPosition + spDelta.y;
animation.play();
}
} }
来源:https://stackoverflow.com/questions/11897035/flex-spinnerlist-how-animate-spin