Beenden
  • Globale Community
    • Sprache:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

At a loss — How do I get my animation to loop a set number of times before stopping?

Entdecker ,
Oct 16, 2019 Oct 16, 2019

I'm a beginner. Sorry! But I've created an animation that works. It's simple and very straight forward.

 

But it doesn't do what I want which is to start when I click "Start" then loop three times and stop at the end of the animation at frame 58.

 

Here's what I have:

in Layer 1, frame 1 of the animation I have this:


var _this = this;
_this.stop();

 

In Layer 1, frame 2 and to the end (frame 58 is end) I have this:

 

if (!this.looped) this.looped = 1;

if (this.looped++ > 3) this.gotoAndStop('58');

 

In Layer 2, frame 1 and to the end I have this (and a "Start" button):


var _this = this;
_this.button_2.on('click', function(){
_this.gotoAndPlay('2');
});

 

Animation starts when I click "Start" but it only plays once, then goes back to beginning and stops. It seems my "Stop" in Layer 1, frame 1 overrides the loop command? But what do I do to prevent the animation to auto play on load if I don't have a Stop action in there?

THEMEN
ActionScript , Code , Anleitungen , Zeitrahmen
6.3K
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines

correct answers 1 richtige Antwort

LEGENDE , Oct 17, 2019 Oct 17, 2019
Übersetzen
LEGENDE ,
Oct 17, 2019 Oct 17, 2019

It sounds like you're creating a banner ad. But your code is AS3, which won't work in an HTML5 Canvas document, which is what you have to use for ads now.

 

Which is it?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Oct 17, 2019 Oct 17, 2019
HI, I'm creating a simple animation to be placed on a page on a website. Not a banner ad. So far I've gotten a little farther than above, but still not getting it right. For now, the video loops the number of times I like and then stops. BUT, as soon as I add in a "Stop" function, the looping won't work. I want the animation to start when I click "Start", not auto-play as soon as page loads. But I can't figure out where on the timeline to place the Stop without it interfering with the loop command. Can I send you a file somehow?
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Oct 17, 2019 Oct 17, 2019

You seem to have ignored the part of my post where I said you can't use AS3 code. You can't use AS3 code. You have to use JavaScript. Look at the code hints for Canvas documents. Look at the browser developer console for errors when testing the page.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Oct 17, 2019 Oct 17, 2019
Not ignoring anything — I'm just not very skilled in this or understand coding. I was hoping to get a piece of code to insert rather than a reference to hints and JavaScript. I am a little old lady who doesn't program...
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Oct 17, 2019 Oct 17, 2019

I've revised my original post to include the actual code I've used. Would greatly appreciate help with this!

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Oct 17, 2019 Oct 17, 2019

Hey Hanna. Here is an example of how you could do it.

 

https://app.box.com/s/toxn0ixv2944r0yv5emuj6joh5smi60c

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Oct 17, 2019 Oct 17, 2019
Eagerly waiting to find out what solution you were going to show me 😉
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Oct 17, 2019 Oct 17, 2019
Why do you have your frame numbers in quotes? Did you create frame labels "58" and "2"?
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Oct 17, 2019 Oct 17, 2019
I got the code from this forum and copied it and updated with my own frame numbers. I have not set labels. Don't know how to do that.
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Oct 17, 2019 Oct 17, 2019
To Resdesign — I'm not sure what to learn from the .fla file you sent me. It loops indefinitely for me. And it also doesn't have a start button so it auto plays. If you see my original post, I'm explaining my issue there. I'm a beginner here so please bear with me!
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Oct 17, 2019 Oct 17, 2019
This is strange. It loops only 3 times for me and stops. Agreed about the frame number It should not be in quotes. Anyway, I was not trying to make the whole thing for you, only showing you a way to stop after playing 3 times. Please play it again. I added a visible counter for you to see. download it again. Code is in the movie clip. https://app.box.com/s/toxn0ixv2944r0yv5emuj6joh5smi60c
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Oct 17, 2019 Oct 17, 2019
please press enter from ANCC to play in you default browser. there is no way this plays continually in any browser.
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Oct 17, 2019 Oct 17, 2019
Yup. Just keeps playing and playing when I do "Test" — maybe I'm using the wrong way to test it? And the counter just says "counter" and doesn't show any numbers per loop. I stopped counting at 6th loop. Weird!
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Oct 17, 2019 Oct 17, 2019

you must be doing it wrong. from ANCC, press ctrl-enter or cmd-enter. It should open your browser.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Oct 17, 2019 Oct 17, 2019
Same result. It plays and plays. But did you look at my original issue? I can get my animation to loop the number of times I want but I need a Stop action in the beginning so it doesn't auto-start. Where do I put that "Stop" action so it doesn't interfere with the loop once started? Can I send it to you? How?
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Oct 17, 2019 Oct 17, 2019

That's insane! I tried it on multiple browser and this is the correct way to do it.

If it is a video, then in the component parameters check off autoplay.

video no autoplay.png

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Oct 17, 2019 Oct 17, 2019
I uploaded my animation in case you can take a look at it. Maybe it works for you since nothing works for me when it should... https://app.box.com/s/rbl4unpj76yp8gznfthkj6w6dpy4bkjj
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Oct 17, 2019 Oct 17, 2019
I'm using Adobe Animate, if that makes a difference. Not doing anything other than opening your file in Animate and then Cmd + Return.
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Oct 17, 2019 Oct 17, 2019
Oh, and I had to put back the ' ' around the frame numbers or it wouldn't work at all.
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Oct 17, 2019 Oct 17, 2019
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Oct 17, 2019 Oct 17, 2019
That is almost perfect! Only thing now is that when it's done its loops and you restart, it only runs once but I want it to restart the looping. Question, to make it loop 5 times instead, do I change the "if(i<4){" in frame 59 to "if(i<6){" instead?
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Oct 17, 2019 Oct 17, 2019
yes. 5 is less than 6. You will have to reset i to 0 for it to start again.
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Oct 17, 2019 Oct 17, 2019
Any chance you can tell me how to do that or should I wing it to reset "something" to 0?
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Oct 17, 2019 Oct 17, 2019

Change the code to:

 

i++;

if(i<6){
	this.gotoAndPlay(2);
} else{
	this.gotoAndStop(0);
	
}

 

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines