Copy link to clipboard
Copied
I have a button bank that allows a quick search of a video component instance named "video0". Rather than have a diff. function for each button, can I use one function and just pass to it the location I wish to seek to? I tried this, but no luck...
_root.b1.addEventListener("click", govideo.bind(this,0));
_root.b2.addEventListener("click", govideo.bind(this,100));
_root.b3.addEventListener("click", govideo.bind(this,200));
function govideo(thetime) {
_root.gotoAndPlay("video");
video0.currentTime = thetime;
$("#video0")[0].play();
}
Oops! My bad... The code below is correct. The problem was my video placeholder was not long enough for the time values I had specified. Thanks
_root.b1.addEventListener("click", govideo.bind(this,0));
_root.b2.addEventListener("click", govideo.bind(this,100));
_root.b3.addEventListener("click", govideo.bind(this,200));
function govideo(thetime) {
_root.gotoAndPlay("video");
video0.currentTime = thetime;
$("#video0")[0].play();
}
Copy link to clipboard
Copied
The code you showed seems to work exactly like you have it. At least as far as this line:
function govideo(thetime) {
There may be something going wrong after that. Where is video0 created? If it's a component you may need to do a getElementById() to get the video's reference.
Also, is the frame "video" somewhere that those three buttons don't exist? If they're not present you could add some removeEventListeners before going to the "video" frame:
function govideo(thetime) {
_root.b1.removeEventListener("click", govideo);
_root.b2.removeEventListener("click", govideo);
_root.b3.removeEventListener("click", govideo);
Copy link to clipboard
Copied
Oops! My bad... The code below is correct. The problem was my video placeholder was not long enough for the time values I had specified. Thanks
_root.b1.addEventListener("click", govideo.bind(this,0));
_root.b2.addEventListener("click", govideo.bind(this,100));
_root.b3.addEventListener("click", govideo.bind(this,200));
function govideo(thetime) {
_root.gotoAndPlay("video");
video0.currentTime = thetime;
$("#video0")[0].play();
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now