Skip to main content
Inspiring
June 21, 2007
Question

Undefined sound.duration?

  • June 21, 2007
  • 3 replies
  • 275 views
I've got a math lesson that I'm playing some feedback audio (short narration) using mySound.attachSound("linkage") and I want to make the buttons on stage not accessible until after the feedback.

I used delay=mySound.duration to get the duration of the sound and then I use setTimeout(enableButtons,delay);

It works fine in the testing environment or when I play just the published swf. But if I load that swf into an empty movieclip, mySound.duration returns "undefined." The sound does still play and the scoping is correct. Anybody have any ideas?
This topic has been closed for replies.

3 replies

RothrockAuthor
Inspiring
June 21, 2007
Qualifies as stupidest mistake!

var mySound:Sound=new Sound("theClip");

As soon as I got rid of those quotes it worked great!
Inspiring
June 21, 2007
Rothrock,

>> It works fine in the testing environment or when I play
>> just the published swf. But if I load that swf into an empty
>> movieclip, mySound.duration returns "undefined."

Wow, that's pretty weird. What happens if you wait a single frame's
worth? Trace it on an onEnterFrame loop that kills itself after the first
run. (I'm assuming that you're checking for the duration property after the
clip itself has fully loaded.)


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."


RothrockAuthor
Inspiring
June 21, 2007
PS: The sounds are exported for actionscript in the first frame of the lesson.