Copy link to clipboard
Copied
hi every body..
I've searched long time...
I 'm working on html 5 canvas project using adobe animate cc. I 've mp4 video on the timeline and I have some content on the timeline.
The question is How can I make the timeline start playing when I click on the play button of the video ??
I've used the following, but it did not work...
var pos = 0;
// Assign an ontimeupdate event to the video element, and execute a function if the current playback position has changed
vid.ontimeupdate = function() {myFunction()};
function myFunction() {
pos = Math.round(vid.currentTime*24);
// where 24 is the current frame rate
inputTxt.value = pos;
this.stop(pos+1);
}
Event handlers default to executing in the global window context. Yes, this was a very poorly thought out design decision, but now we're stuck with it.
To force a function to execute in a specific context, you have to use .bind() on it.
Copy link to clipboard
Copied
Sticking an alert(this); in your event handler would be enlightening.
Copy link to clipboard
Copied
A little correctness:
this.play(pos+1); instead of this.stop(pos+1);
Copy link to clipboard
Copied
Neither are correct. Only gotoAndStop() and gotoAndPlay() take frame numbers.
Copy link to clipboard
Copied
I've done that but still not work.. the play head dos not move ..
When I add
alert(this);
inside function myFunction() .. I get [Object window ] message..
The question still How Can I refer to the timeline to play the play head??
Copy link to clipboard
Copied
Event handlers default to executing in the global window context. Yes, this was a very poorly thought out design decision, but now we're stuck with it.
To force a function to execute in a specific context, you have to use .bind() on it.