4 Replies Latest reply on Mar 1, 2007 8:30 PM by kglad

    Play Pause sound in flash 8

    cf_junky
      I really need someons help. I am still learning actionscript, but need a job completed by Monday.
      I got the following script from O'Reilly's web site:
      http://www.oreillynet.com/pub/a/javascript/excerpt/ActionScriptCkbk_chap1/index1.html?page =1

      However, the sound does not pause at all, it just continues to play.
      I have imported the sound file and added the linkage.

      ...code attached.

      Thank you in advance.


        • 1. Re: Play Pause sound in flash 8
          kglad Adobe Community Professional & MVP
          you're missing some code. there must be something that extends the sound class' methods to include a pause() and resume() method. do you have that code from o'reilly's?
          • 2. Re: Play Pause sound in flash 8
            cf_junky Level 1
            Yes there was some code that I somehow overlooked.
            I added it in and now it works perfectly.

            Sound.prototype.pause = function ( ) {
            // Get the current position and then stop the sound.
            this.pauseTime = this.position;
            this.stop( );
            };

            Sound.prototype.resume = function ( ) {
            // Start the sound at the point at which it was previously stopped.
            this.start(this.pauseTime/1000);
            };


            Thank you so much for the prompt reply.

            I see I have a second challege and that is I need to keep the base file small and rather call the sound externally. They are mp3's.

            Is it possible to use the code form O'Reilly or do I need a different approach?

            • 3. Re: Play Pause sound in flash 8
              Level 7
              You should be able to adapt the code you've got. Search the ActionScript2
              book in the help files for "Loading an MP3 file."


              • 4. Re: Play Pause sound in flash 8
                kglad Adobe Community Professional & MVP
                that's not very impressive coding. the pause method is totally superfluous and adds nothing to the already existant stop() method.

                the resume prototype adds a little functionality to the start() method, but not much.

                in any case, there are no errors in that coding and your sound should stop/pause and resume as long as those prototype methods are defined before they are used.

                so, what's calling the pauseSound() function and failing to pause your sound?