public virtual void setFrameSound(int frameID, AsSound sound)
 {
     if (frameID < 0 || frameID >= getNumFrames())
     {
         throw new AsArgumentError("Invalid frame id");
     }
     mSounds[frameID] = sound;
 }
        public virtual void advanceTime(float passedTime)
        {
            int finalFrame    = 0;
            int previousFrame = mCurrentFrame;

            if (mLoop && mCurrentTime == mTotalTime)
            {
                mCurrentTime  = 0.0f;
                mCurrentFrame = 0;
            }
            if (!mPlaying || passedTime == 0.0f || mCurrentTime == mTotalTime)
            {
                return;
            }
            mCurrentTime = mCurrentTime + passedTime;
            finalFrame   = (int)(mTextures.getLength() - 1);
            while (mCurrentTime >= mStartTimes[mCurrentFrame] + mDurations[mCurrentFrame])
            {
                if (mCurrentFrame == finalFrame)
                {
                    if (hasEventListener(AsEvent.COMPLETE))
                    {
                        float restTime = mCurrentTime - mTotalTime;
                        mCurrentTime = mTotalTime;
                        dispatchEventWith(AsEvent.COMPLETE);
                        advanceTime(restTime);
                        return;
                    }
                    if (mLoop)
                    {
                        mCurrentTime  = mCurrentTime - mTotalTime;
                        mCurrentFrame = 0;
                    }
                    else
                    {
                        mCurrentTime = mTotalTime;
                        break;
                    }
                }
                else
                {
                    mCurrentFrame++;
                    AsSound sound = mSounds[mCurrentFrame];
                    if (sound != null)
                    {
                        sound.play();
                    }
                }
            }
            if (mCurrentFrame != previousFrame)
            {
                setTexture(mTextures[mCurrentFrame]);
            }
        }
 public virtual void addFrameAt(int frameID, AsTexture texture, AsSound sound, float duration)
 {
     if (frameID < 0 || frameID > getNumFrames())
     {
         throw new AsArgumentError("Invalid frame id");
     }
     if (duration < 0)
     {
         duration = mDefaultFrameDuration;
     }
     mTextures.splice(frameID, (uint)(0), texture);
     mSounds.splice(frameID, (uint)(0), sound);
     mDurations.splice(frameID, (uint)(0), duration);
     mTotalTime = mTotalTime + duration;
     if (frameID > 0 && frameID == getNumFrames())
     {
         mStartTimes[frameID] = mStartTimes[frameID - 1] + mDurations[frameID - 1];
     }
     else
     {
         updateStartTimes();
     }
 }
 public virtual void addFrame(AsTexture texture, AsSound sound)
 {
     addFrame(texture, sound, -1);
 }
 public virtual void addFrame(AsTexture texture, AsSound sound, float duration)
 {
     addFrameAt(getNumFrames(), texture, sound, duration);
 }
 public virtual void addFrameAt(int frameID, AsTexture texture, AsSound sound)
 {
     addFrameAt(frameID, texture, sound, -1);
 }