First, this was written in Macromedia.Director.MX.2004. Now, trying to make an upgrade to 11.5 when I saved and run this, it says it can't divide by zero and the line
it points out is "percentPlayed = pCurrentTime / float(pDuration)"
This script is a moving bar in a audio player as a curret time indicator.
pSprRef = sprite("MovingBar")
pLeft = sprite("MovingBarBack").left
pRight = sprite("MovingBarBack").right
pCurrentTime = 0
pSoundMember = sound 1
pDuration = sound(1).endTime
pSoundChannel = sound(1)
if pSoundChannel.isBusy() then
pCurrentTime = pSoundChannel.currentTime
percentPlayed = pCurrentTime / float(pDuration)
newLocH = ((pRight - pLeft) * percentPlayed)
pSprRef.width = newLocH
sprite(39).locH = sprite(28).right
I would really appreciate any help.
What does sound(1).endTime evaluate to? If it's zero then you have the problem described?
You're likely getting this error when there is no sound playing since director will then interpret it as a zero (as Sean explained).
Move "pDuration = sound(1).endTime" to after the line "if pSoundChannel.isBusy() then" and it should work.
Yes, but if there is no sound playing then isBusy() will return false and the division won't be performed. There's something hinky going on - perhaps with the sound file/member?