连续旋转图像

时间:2011-07-10 15:47:32

标签: flex actionscript-3

我想在页面加载时连续旋转图像。代码在页面加载时可以正常旋转1次但是为了连续地实现相同的效果,我将.play()语句包含在无限while循环中,如下所示。但它会导致页面挂起而没有任何显示。

while (i == 1)
{
    if (rotEff.isPlaying != true)
    {
        rotEff.play();
    }
}

关于如何实现这种效果的任何指示都会有很大的帮助

3 个答案:

答案 0 :(得分:5)

尝试将repeatCount对象的Effect属性设置为0,以便无限期重复:

<fx:Declarations>
    <s:Rotate id="rotate" target="{image}" angleBy="360" duration="1000" repeatCount="0" autoCenterTransform="true"></s:Rotate>
</fx:Declarations>

<强> [UPDATE]

回应沙的评论:

  

感谢taurayi ...设置repeatCount解决了这个问题。但是那里   是从一个完整的360轮到一轮的过渡延迟   另一轮......也可以摆脱那个......?

easer属性设置为null,如下所示:

<fx:Declarations>
    <s:Rotate id="rotate" target="{image}" angleBy="360" duration="1000" repeatCount="0" autoCenterTransform="true" easer="{null}"></s:Rotate>
</fx:Declarations>

答案 1 :(得分:0)

很简单。只需设置一个输入框架监听器,以便在发生加载时运行(不要使用时间轴动画)。

obj.addEventListener(Event.ENTER_FRAME, doRotate);

function doRotate(e:Event):void{
    obj.rotation += 1; //in whatever direction / orientation / increment you wish
}

加载完成后,只需删除监听器即可。

答案 2 :(得分:-1)

如果这是Flex应用程序,我建议您使用Timer对象。

相关问题