1 Reply Latest reply on Dec 31, 2007 1:06 PM by Newsgroup_User

    AS2.0: Clearing Sound Position


      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.

      Your replies will be appreciated!

        • 1. Re: AS2.0: Clearing Sound Position
          Level 7

          You're saying that repeated clicks of the startClip movie clip cause
          your Sound instance (soundTest) to play more than once? If so, I can't
          explain why that would happen. I do recommend, however, that you declare
          your variables formally with the var keyword, including the pausePositionS
          variable, outside of your event handlers ...

          var soundTest:Sound = new Sound();
          soundTest.attachSound("slide 1");
          var pausePositionS:Number = 0;

          // etc. Event handlers follow as before.

          Otherwise, the pausePositionS variable gets declared and set for you
          automatically inside the onPress handler. You want it scoped to the main
          timeline, along with the rest of your code.

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