I think I have found the function that seems to be closer to what I want to do.
_ani_Controler.prototype.play = function (motionName, reset) {
var data = this.motions[motionName]; // get data for run this spine state
var state = this.spine.state; // state scoped for listener
state.setAnimation(data.track, data.state, true); // LOOP IDLE1 track:0
state.tracks[0].listener = {
complete: function(trackEntry) {
// Each complete loop , check for play wink at random timeLine (timeLength of animation)
var count = trackEntry.loopsCount();
var rand = ~~(Math.random()*100)+1;
if(rand>50 && !(count%2)){
var ranWait = (Math.random()*trackEntry.nextAnimationLast); // wait time 0 to 1.295000000000015
state.addAnimation(1, 'wink1', false, ranWait); // work, but only one time ???!!!***
};
}
};
return this;
};
So logicly, when i do state.setAnimation(..) on tracks[0].
i also add a listener to the tracks[0].
When it complete, random check if can play wink .
If yes, get the time length of next animation, and get random value from this time length.
And wink addAnimation(..) on tracks[1];
I don't know if I express myself well.
where I stuck a little bit is why wink play only one time!
I have the impression that it is necessary to make a reset on tracks[1], but i don't know how.
EDIT::
ho thank for the API link
it solved with state.clearTrack(1);
Now i just have to find how i can get the animation length time
and make a random time with it.
how i can calculate the time length of a animation and pass it to delay
state.addAnimation(1, 'wink1', false, delayAnimation);
EDIT2:
ok solved
trackEntry.animation.duration
thank a lot @Nate for help
:sun: :sun: :sun: