Skip to main content
Participating Frequently
April 26, 2006
Answered

How To Stop Animation Looping?

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'.
This topic is closed to new replies. Start a new post to keep the conversation going.
ogousa-swS9lVCorrect answer
Participating Frequently
May 1, 2006
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

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;
}

11 replies

Participant
April 28, 2006
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();

Translate
Participating Frequently
April 28, 2006
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
Translate
Participating Frequently
April 28, 2006
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
Translate
Participating Frequently
April 26, 2006
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.
Translate
Participant
April 27, 2006
insert stop(); in the animation layer can stop the animation
Translate
Participating Frequently
April 27, 2006
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?
Translate