Copy link to clipboard
Copied
All I want is a simple control to scrub a Movie Clip, an easy thing to do in AS3 and has been done in Edge.
Referencing Sarah Justine's Create Click and Touch Draggable Scrubbers with Edge Animate CC for her Simple Horizontal Scrubber, I created all the clips referenced in her canvas on mine, with instance names and placed her code in a keyframe. Naturally this did not work.
Has anyone successfully edited her code to work in AnCC? Is there a guide somewhere to help convert Edge code for AnCC?
var symDur = sym.getSymbol("timelinePlay").getDuration(); // Get the timeline length of timelinePlay. We'll reference this later in the code.
var mySymbol = sym.getSymbol("timelinePlay"); // Get the symbol timelinePlay. We'll reference this later in the code.
var scrubber = sym.$("scrubber"); // Touch this to scrub the timeline of timelinePlay
var bar = sym.$("bar"); // Bar the scrubber follows
sym.$("mobileHit").hide(); // Added an extra invisible div to increase the hit region for mobile (hard to grab otherwise)
var dragme = false; // Set the initial dragme function to false
// Detect if mobile device, and if so swap out mouse events for touch events. This is pretty much duplicated code with touch events swapped.
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) {
sym.$("mobileHit").show(); // Show the extra invisible div to increase the hit region for mobile (hard to grab otherwise)
$(function () {
scrubber.bind("touchstart", function (e) { // Enable the scrubber on touchstart
e.preventDefault(); // Cancels the default action of the mobile device - used to ensure our touch events are fired
dragme = true;
});
scrubber.bind("touchend", function () { // Disable the scrubber on touchend
e.preventDefault();
dragme = false;
});
scrubber.bind("touchmove", function (e) { // Make the magic happen on touchmove
if (dragme) {
var touch = e.originalEvent.touches[0];
var possibleX = touch.pageX;
var leftX = bar.offset().left;
var rightX = (leftX + bar.width()) - scrubber.width();
var scrubWidth = rightX - leftX;
// Confine the scrubber to the width of the bar
if (possibleX < leftX) {
possibleX = leftX;
}
if (possibleX > rightX) {
possibleX = rightX;
}
scrubber.offset({
left: possibleX
});
var relativeX = possibleX - leftX;
var stopTimeline = Math.ceil((relativeX / scrubWidth) * symDur); // Make the scrubber scrub the timeline length of timelinePlay
mySymbol.stop(stopTimeline); // Stop the timeline of timelinePlay when the scrubber is released
}
});
})
}
else $(function () {
scrubber.mousedown(function () { // Enable the scrubber on mousedown
dragme = true
})
$(document).mouseup(function () { // Disable the scrubber on mouseup
dragme = false
})
$(document).mousemove(function (e) { // Make the magic happen on mousemove
if (dragme) {
var possibleX = e.pageX;
var leftX = bar.offset().left;
var rightX = (leftX + bar.width()) - scrubber.width();
var scrubWidth = rightX - leftX;
// Confine the scrubber to the width of the bar
if (possibleX < leftX) {
possibleX = leftX;
}
if (possibleX > rightX) {
possibleX = rightX;
}
scrubber.offset({
left: possibleX
});
var relativeX = possibleX - leftX;
var stopTimeline = Math.ceil((relativeX / scrubWidth) * symDur); // Make the scrubber scrub the timeline length of timelinePlay
mySymbol.stop(stopTimeline); // Stop the timeline of timelinePlay when the scrubber is released
}
})
})
I tried to add "this." to symbol references in her code and even removing the entire "Detect if mobile.." if statement and still nothing renders on the published page.
I have searched all over the web for info on how to make a Timeline Scrub among other common tasks in AnCC, but all appear to be quite a holy grail, oddly.
Is anyone aware of a better way to achieve this either with her code or something else? Are there any resources for finding out how to create useful, interactive elements on Canvas using AnCC anywhere?
Thanks in advance.
Copy link to clipboard
Copied
I don't have time right now to go through all that, but first thing I see that I'd rip out is all the jQuery. CreateJS is perfectly capable of handling its own mouse events.
Copy link to clipboard
Copied
Thanks for that,
I replaced lines of code like sym.getSymbol("timelinePlay").getDuration(); with this.timelinePlay.getDuration();
and $(document).mouseup(function () with scrubber.mouseup(function () - but the timeline scrub is still not working.
There must be existing code for this function somewhere?
Thanks again.
Copy link to clipboard
Copied
Did you find anything? I would like the same.
Copy link to clipboard
Copied
I found something, I'll post what I found in the thread... frustrating, isn't it?
Copy link to clipboard
Copied
So, in my ceaseless quest to try and get Animate CC to do something useful like simply scrub a timeline I found this from a clever fellow named Joseph Labrecque:
Animate CC: HTML5 Canvas Timeline Scrubber
http://inflagrantedelicto.memoryspiral.com/2018/08/animate-cc-html5-canvas-timeline-scrubber/
This solution is pretty damned nice, I am trying to modify his code for use inside a movie clip; to scrub its timeline instead of the main timeline... which would be useful for getting AnimateCC to allow very common UI features such as scrollable text.
I am having trouble modifying his code to do just that... maybe if someone more knowledgeable had a look at that code they might offer some suggestions here?
Thanks!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now