How do I detect frame count?

Fill this out this info to make it easier for the community to help you! If you don’t fill out this information, your post may be deleted or removed.

What Wick Editor Version are you using?
1.19.3

Describe the Problem
I’m trying to make something that chooses between all of the frames and want it to choose a random frame out of all of them.
Basically, I want to be able to detect how many frames are in a clip

What have you tried so far?
I don’t know what to try

i dont really know how to detect frame count, but i think if you count it out, you can still do that random frame thing

for example,

if (project.variable == 69) {
posingman.gotoAndStop(random.integer(1, 10));
};

i hope this helps you out.

To find out how many layers are in a clip:

this.layersCount = this.timeline.layers.length;

To find out how many frames are inside a layer:

this.firstLayerFrameCount = this.timeline.layers[0].frames.length;

(Increase the 0 inside the brackets to find how many frames are inside another layer)


To find out how many total frames are inside of the clip:

var a = 0;
this.timeline.layers.forEach(function(value){
a += value.frames.length;
})
this.totalFrames = a;

(Note: Let’s say you had 3 frames, each one is 2 frames long, last one stopping at 6, this.totalFrames will be set to 3 and not 6)


To find out where the frames stop (at what number):

var a = 1;
this.timeline.layers.forEach(function(value){
value.frames.forEach(function(frame){
if(frame.end>a){
a=frame.end;
}
})
})
this.timelineEnd = a;

:warning: If you use any of the code above, make sure to place it inside of the default script


I hope this helped :)

To summarize:

clip // = the name of the clip
clip.timeline // = refers to the timeline of the clip
clip.timeline.layers // = an array of all the layers inside the timeline 
clip.timeline.layers[0].frames // = an array of all the frames inside a layer
clip.timeline.layers[0].frames[0].end // = where a frame stops in the timeline

Also, :tada: welcome to the forums @lazybutter!
: )