Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Timeline Scrub: Using Edge Animate code in Animate CC HTML5

Engaged ,
Apr 20, 2018 Apr 20, 2018

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.

929
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 20, 2018 Apr 20, 2018

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.

EaselJS Tutorial: Mouse Interaction

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 20, 2018 Apr 20, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2018 Jun 07, 2018

Did you find anything? I would like the same.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 01, 2018 Oct 01, 2018

I found something, I'll post what I found in the thread... frustrating, isn't it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 01, 2018 Oct 01, 2018
LATEST

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines