Stop and start all clips of the main timeline

Hi,
Is there a way to stop and start all clips of the main timeline? While avoiding clip1.stop(); clip2.stop(); etc.
Thank you.

To can do play() or start()

So, what you can do is:

// Get all clips in the current frame.
// Then, get Clips/Buttons in it. (array)
// Now, for each clip, stop it!
project.activeFrame.clips.forEach( (clip) => { clip.stop(); })
1 Like

If you’re editing code inside of a clip, then use

project.stop() //and project.play() or
project.YourClipHere.stop(), vice versa.

1 Like

You don’t need to have project in front of it

1 Like

Thank you for your answers.
The goal was to trigger the code from a MouseClick event on a button.

project.activeFrame.clips.forEach( (clip) => { clip.stop(); }) // or gotoAndStop(0)

perfectly did the job, thank you.

However, somehow, play() and stop() or project.play() and project.stop(), had not result.

Additional question, if the code is now in a different layer from the animation, activeFrame won’t work. Is there a way to make this code run in frame myFrame of another layer? Thank you.

Really? Those are used to stop and play everything on the main timeline

Hi @LapisLazuli, I’m grateful that my spaghetti solution worked! The reason why stop() and play and their project version didn’t work was that:

For the stop() and play() options:

These stop and start the root clips’ timeline (WHAT?), yes, the project’s timeline is a clip. That doesn’t stop the clips that are inside the frame.

For the project. version:

Those aren’t real methods in Wick.Project (the special thing that makes projects).

The question:

project.activeFrame selects the literal active frame, this means that if a different layer is selected, that layers’ active frame (the timeline frame) is affected. To fix this, try this one:

# Now, this is really weird:
# Get the timeline
# Get ALL active frames
# Get ALL clips
# Stop EACH clip.
project.timeline.activeFrames.forEach( (frame) => frame.clips.forEach( (clip) => clip.stop() ) );

Should it work now. I battle-tested and built it in the editor.

1 Like

Hi @noobfield, thanks for the detailed explanations and solution. Works perfectly!

Your code will work wherever the frame is located. In my case, by construction, all clips run in the first frame of the first layer, as shown on this screenshot:

image

So this simplified version, derived from your code, works for me as well:

project.timeline.activeFrames[0].clips.forEach( (clip) => clip.stop() );

That is, replacing the looping through all frames, by activeFrames[0]

Side question: I guess that there is currently no way to refer to a frame by its name, correct? Something like activeFrames[“AnimFrame”] or activeFrames.AnimFrame…

Thank you.

Sorry I couldn’t help you I was confused at what you wanted

Really, no problem at all. You meant to help! And it confirmed to me that my first attempt, using stop() and play() weren’t that dumb after all, even for a newbie :slight_smile:
I should have explained that all my animations were in clips, so as @noobfield correctly guessed and explained, there is nothing to stop in the main timeline. Only in each clips’ dedicated timeline.

1 Like

I like animating in clips too

Yea, that’s a funny implementation thing. Wick’s main way of making “animateables” is Clips (if you discount buttons, those are separate), also due to the way they were made, it’s possible to migrate a Wick.Clip into Wick.Custom.Sprite.