Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 我的';微调器';动画停止_Actionscript 3_Flash_Animation_Loading - Fatal编程技术网

Actionscript 3 我的';微调器';动画停止

Actionscript 3 我的';微调器';动画停止,actionscript-3,flash,animation,loading,Actionscript 3,Flash,Animation,Loading,我有一个简单的“进度”类,它控制我的旋转点和进度条。 问题是,在加载组件时,我的点有时会停止动画。这是我的密码: protected static const CONST_DOTS_ANIM_DELAY = 85; protected var m_tDotsAnimTimer:Timer; m_tDotsAnimTimer = new Timer( CONST_DOTS_ANIM_DELAY ); m_tDotsAnimTimer.addEventListene

我有一个简单的“进度”类,它控制我的旋转点和进度条。 问题是,在加载组件时,我的点有时会停止动画。这是我的密码:

    protected static const CONST_DOTS_ANIM_DELAY = 85;
    protected var m_tDotsAnimTimer:Timer;

    m_tDotsAnimTimer = new Timer( CONST_DOTS_ANIM_DELAY );
    m_tDotsAnimTimer.addEventListener(TimerEvent.TIMER, DotsAnimHandler);


    public function DotsAnimHandler(event:Event):void
    {
        mcSpinnerDots["mcFadeDot"+m_nCurrentDot].gotoAndPlay( 2 );
        m_nCurrentDot++;
        if( m_nCurrentDot == 8 )
        {
            m_nCurrentDot = 0;
        }
    }


    public function ShowSpinner():void
    {
        mcSpinnerDots.visible = true;
        m_tDotsAnimTimer.start();
        visible = true;
    }

谢谢:)

我有一种强烈的感觉,在你的处理器上,你调用一个不存在的点,你看不清楚它,因为你调用它,尽管[]

在处理程序的第一行上跟踪(mcSpinnerDots[“mcFadeDot”+m_nCurrentDot]),查看它是否返回点的值

您还可以使用以下代码行优化计数器

m_nCurrentDot = (m_nCurrentDot + 1) % 9; // range from 0 to 8
而不是

m_nCurrentDot++;
if( m_nCurrentDot == 8 )
{
   m_nCurrentDot = 0;
}
它既能更快地工作,又能看起来更好


希望有帮助

creative magic有一些很好的建议,但是如果你有一个带有8个点的循环动画,而不是在舞台上有8个资源并分别管理它们,那么将它们制作成一个mc。这就取消了计时器的需要

仅仅因为它很少在课堂或教程中教授,我想补充的是,这种优化(n%t)被称为模数,是寻找剩余的一种非常快速的方法