Copy link to clipboard
Copied
Hello I am new to adding scripts into my timeline. My question is about looping only a specific number of frames in my timelline not the entirety of my project. My goal is to replay a set of frames. These set of frames are the same in length but are spread into 6 Layers to depict motion, backgrounds, etc. I want these 6 layers to replay a seemingly infinite amount of times until a button is pressed navigating the user to another set of looping frames until that button is pressed and so on and so forth.
Do i need to make all 6 layers a movie clip or is there a script I can use that would make said frames loop until navigated elsewhere via a button?
Please give me a hand! Thanks
1. Create a new layer at the top of your timeline and label it "actions". This is where you want to put your actionscript.
2. Go to the last frame of your first loop section and put a keyframe in the actions layer.
3. Open the Actions window and type in "gotoAndPlay(X); where X is the frame number for the first frame in this first loop section.
So, for instance, you put the command gotoAndPlay(180) in frame 200, every time the playback head gets to frame 200 it will jump to frame 180 and continue
...Copy link to clipboard
Copied
1. Create a new layer at the top of your timeline and label it "actions". This is where you want to put your actionscript.
2. Go to the last frame of your first loop section and put a keyframe in the actions layer.
3. Open the Actions window and type in "gotoAndPlay(X); where X is the frame number for the first frame in this first loop section.
So, for instance, you put the command gotoAndPlay(180) in frame 200, every time the playback head gets to frame 200 it will jump to frame 180 and continue to play. When it gets to frame 200 it will loop back again, and again...
If you have a button in the section between frames 180 and 200 that moves the playback head to a frame outside of this section then the playback head will jump to the new frame and play from there. You can set as many of these loops as you like.
Copy link to clipboard
Copied
I have an actions Layer already I just didn't add it into my snip lol.
So basically I choose the last frame of the first set of frames I wish to loop. Add a go to and play and set the ( ? ) to the first frame of the set. Add my button at the first frame as well so it show up throughout the loop. Set my button action to go to and play the next set of frames I choose following the first set that is looping?
Copy link to clipboard
Copied
Yep, that's pretty much the process. Be sure that the button on exists in the looping section.
Copy link to clipboard
Copied
robdillon wrote
Yep, that's pretty much the process. Be sure that the button on exists in the looping section.
This will guarantee that another event listener gets added every time it loops, unless guard logic is applied.
Copy link to clipboard
Copied
It's AS3, it doesn't work like Javascript (adding the same listener to the same object still leaves you with one listener), though there would be no harm in doing an unneeded hasEventListener();
Copy link to clipboard
Copied
Well that's handy. A shame CreateJS doesn't work that way.
Copy link to clipboard
Copied
With CreateJS you can use addEventListener("whatever"), or .on("whatever"). I believe the on variation does stop extra listeners.
Copy link to clipboard
Copied
It does not. For as many problems as this cumulative behavior causes I'd hope Adobe would correct it in CreateJS, but so far it seems like they're not interested in doing so.
EaselJS v0.8.2 API Documentation : EventDispatcher
"...each time you call on
a NEW wrapper function is subscribed, so multiple calls to on
with the same params will create multiple listeners."
Copy link to clipboard
Copied
Yep, that's pretty much the process. Be sure that the button only exists in the looping section. Sorry for the typo.
Copy link to clipboard
Copied
I looked at other posts but none made it as simple as you did. Thanks a ton!
Copy link to clipboard
Copied
You're welcome, I could write you a 30 step version that involves waving a chicken over your head if you like!
Good luck with your project.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now