I'm building an e-learning package and I'm using Play/Pause
buttons for voiceovers for different movie clips. I have separate
movie clips for slides and a separate layer for the audio
functions. Here's my script:
When 'startClip' is pressed, it triggers the pausePositionS
function - the sound plays from where it was paused as programmed
in pausePositionS function. The catch is that when I resume
playback after pausing, it's working fine. However, if I 'repress'
the play button, it duplicates the playback from pausePositionS
time again, resulting in 2 copies. The 'n' number of times I press
play, the 'n' number of times it starts playing back again!
Even though people won't really click on the Play button more
than once, some people like ME would just want to experiment and
report bugs! I want to avoid this.
You're saying that repeated clicks of the startClip movie
your Sound instance (soundTest) to play more than once? If
so, I can't
explain why that would happen. I do recommend, however, that
your variables formally with the var keyword, including the
variable, outside of your event handlers ...
var soundTest:Sound = new Sound();
var pausePositionS:Number = 0;
// etc. Event handlers follow as before.
Otherwise, the pausePositionS variable gets declared and set
automatically inside the onPress handler. You want it scoped
to the main
timeline, along with the rest of your code.