11 Replies Latest reply on May 2, 2006 6:13 AM by ogousa-swS9lV

    How To Stop Animation Looping?

    username132
      What I'm trying to do is make it so than when you load my html-based homepage, the logo is animated and plays a sound. When the sound is over, the logo should cease to animate and be static for every other page. I have the logo as a .png already on the page and would like people without flash to still be able to see the static logo.

      How do I;
      a) make the animation stop after the sound completes (currently it loops a peice of the sound and loops the animation)
      b) make the flash animation appear to those with flash and the .png to those without?

      I don't know if it's relevant, but the animation is a glow made with the ActionScript 2.0 and the sound is something I imported to a second 'layer'.
        • 1. Re: How To Stop Animation Looping?
          username132 Level 1
          Progress report;
          By inserting "stop ()" in the 'Action' section with the script for animation, I managed to stop the sound from looping, but the animation continues.
          • 2. Re: How To Stop Animation Looping?
            Abyu
            insert stop(); in the animation layer can stop the animation
            • 3. Re: How To Stop Animation Looping?
              username132 Level 1
              If I right click on the animation layer and click 'actions', I see my code;

              box_mc.filters = [new flash.filters.GlowFilter(0xF0F727)];
              var dir:Number = 2;
              box_mc.blur = 10;
              box_mc.onEnterFrame = function() {
              box_mc.blur += dir;
              if ((box_mc.blur >= 30) || (box_mc.blur <= 4)) {
              dir *= -1;
              }
              var filter_array:Array = box_mc.filters;
              filter_array[0].blurX = box_mc.blur;
              filter_array[0].blurY = box_mc.blur;
              box_mc.filters = filter_array;
              };

              stop()

              but this already contains a stop()... are you telling me to put stop() in some other way?
              • 4. Re: How To Stop Animation Looping?
                Abyu Level 1
                try adding the stop this way

                box_mc.filters = [new flash.filters.GlowFilter(0xF0F727)];
                var dir:Number = 2;
                box_mc.blur = 10;
                box_mc.onEnterFrame = function() {
                box_mc.blur += dir;
                if ((box_mc.blur >= 30) || (box_mc.blur <= 4)) {
                dir *= -1;
                }
                var filter_array:Array = box_mc.filters;
                filter_array[0].blurX = box_mc.blur;
                filter_array[0].blurY = box_mc.blur;
                box_mc.filters = filter_array;

                stop();

                • 5. Re: How To Stop Animation Looping?
                  ogousa-swS9lV Level 1
                  To stop animation after the sound completes, you have to do something like this:
                  music = new Sound();
                  music.loadSound(intro, true);
                  music.onSoundComplete = function()
                  {
                  // stop your animation here!
                  }

                  ogousa
                  Matter of Time
                  • 6. Re: How To Stop Animation Looping?
                    username132 Level 1
                    I'm sorry but I don't think I'm getting it right. Here's what I did;

                    music = new Sound("Intro.mp3");
                    music.loadSound(intro, true);
                    music.onSoundComplete = function()
                    {
                    stop();

                    box_mc.filters = [new flash.filters.GlowFilter(0xF0F727)];
                    var dir:Number = 2;
                    box_mc.blur = 10;
                    box_mc.onEnterFrame = function() {
                    box_mc.blur += dir;
                    if ((box_mc.blur >= 30) || (box_mc.blur <= 4)) {
                    dir *= -1;
                    }
                    var filter_array:Array = box_mc.filters;
                    filter_array[0].blurX = box_mc.blur;
                    filter_array[0].blurY = box_mc.blur;
                    box_mc.filters = filter_array;
                    };

                    }

                    But this stops the animation altogether. Does the fact that the sound comes from another layer on the time line have anything to do with this? Also, all the code is in the 'Actions' on the image layer.

                    I've uploaded the file if it helps to see what I'm doing and you can be bothered to download it! It's 1.8 Mb and is located at http://username132.tasminslair.com/Potato%20Animation.fla Either way, thanks for any help
                    • 7. Re: How To Stop Animation Looping?
                      ogousa-swS9lV Level 1
                      First of all, I can't download your file - link doesn't work
                      Your example is incorrect. It should be:

                      music = new Sound();
                      music.loadSound("Intro.mp3", true);
                      music.onSoundComplete = function()
                      {
                      // assuming that your animation movie is box_mc, and the animation is in onEnterFrame
                      _root.box_mc.onEnterFrame = null;
                      }
                      ...
                      The rest of your code
                      ...

                      You can place code on any level, it doesn't matter. Usually it is Actions level on the top of all levels. Place all your code there if you want to follow good practice.

                      ogousa
                      Matter of Time
                      • 8. Re: How To Stop Animation Looping?
                        username132 Level 1
                        Sorry, it hadn't uploaded because it was open whilst I was trying to upload it! It should work now. I tried putting the code in as you suggested but an error came up saying it couldn't find the intro.wav file (I changed it to .wav when I realised that this was the extension of the file I had imported into the library). It gave the expected path as being in My Documents. So I put a copy of the file there, and the error went away, but the animation continues after termination of the sound.

                        Also, I think we have a misunderstanding. This action script appear to be wanting to import the sound from My Documents, even though I've already imported it to the library and given it a second layer. If I delete this layer however, the sound does not play even with the action script.

                        File;
                        http://username132.tasminslair.com/Potato%20Animation.fla

                        Sound;
                        http://username132.tasminslair.com/Intro.wav
                        • 9. Re: How To Stop Animation Looping?
                          ogousa-swS9lV Level 1
                          I have download your file and made some modification. You can download modified file from
                          here. (I will delete it tomorrow)
                          You place your sound on a layer - that's why it plays independently. You have to set linkage for Intro object in the library, attach sound to music object and then play it. (Or you can remove Intro from library and play it like stream from your server)

                          music = new Sound();
                          music.attachSound("intro");
                          music.start();

                          That's it!

                          If you want to stop animation on a particular phase, don't stop it here:
                          music.onSoundComplete = function()
                          {
                          _root.box_mc.onEnterFrame = null;
                          }

                          but just set a flag and stop the animation inside onEnterFrame function.
                          music.onSoundComplete = function()
                          {
                          flag = 1;
                          }
                          and inside onEnterFrame - set something like:

                          if ((box_mc.blur >= 30) || (box_mc.blur <= 4)) {
                          if(flag==1) this.onEnterFrame = null;
                          }

                          • 10. Re: How To Stop Animation Looping?
                            username132 Level 1
                            Perfect! You anticipated my next question exactly with the bit about flags. I changed the wings to make them opaque and it's now exactly like I dreamed! Thank you!!
                            • 11. Re: How To Stop Animation Looping?
                              ogousa-swS9lV Level 1
                              I'm glad to help! Good luck!