Hi, just wondering if anyone can provide a solution. I feel like I’m quite close in that there is some random timing in the animation, but it’s not quite right.

What I am trying to achieve is have a column of blocks, like LEDs on a graphic equaliser, and for them to animate, fade in to a random height, so 3 blocks light up, then 5, then 2, then 8, then x, y, z… etc.

I have set up an animation where each block is animated from off to on in succession, bottom block first, then second, then third, fourth, fifth etc.

What I would like to do through code is for the script be triggered at the first frame of the animation. At this point I know the total animation length, get a random frame number from start to end. Play the animation. When the random number is reached the animation is continued in reverse, until the first frame is reached, a new random number is generated and the process is repeated. I have placed text elements in the scene to see if the current frame number and random number is being updated… and they are. But somewhere they random number gets stuck close to 0 and then behaves wildly, jumping quickly to different digits.

Thanks for any help.

Gleb

```
var AniName = 'LED_Random';
var AniLength = hypeDocument.durationForTimelineNamed(AniName);
var RandomFrame = Math.floor(Math.random() * AniLength);
window.setInterval(function(){
var CurrentFrame = Math.floor(hypeDocument.currentTimeInTimelineNamed(AniName));
hypeDocument.getElementById("length").innerHTML = CurrentFrame;
hypeDocument.getElementById("random").innerHTML = RandomFrame;
if (CurrentFrame > RandomFrame) {
hypeDocument.continueTimelineNamed(AniName, hypeDocument.kDirectionReverse);
}
}, 1000);
```