Skip to main content
Known Participant
June 28, 2016
Answered

Go to and play frame javascript in Animate CC

  • June 28, 2016
  • 2 replies
  • 40582 views

Hi!

I have a timeline inside Animate as a canvas-doc.

There's 40 frames on the timeline.

When the playhead reaches frame number 40 I want it to go back to frame number 20 and play it and continue to play until reached frame 40 and so on.

I just want the playhead to follow the timeline and automatically play the right frames.

It used to be called something like "goto.play(20)" i actionscript, but what is the javascript for this?

    This topic has been closed for replies.
    Correct answer Colin Holgate

    this.gotoAndPlay(20);

    Note that although you see the timeline going from 1 to 40, in Javascript the frames count from zero. If you want to jump back to the frame with 20 by it, that would be this in Javascript:

    this.gotoAndPlay(19);

    2 replies

    Alama.be
    Known Participant
    July 23, 2018

    Bonjour à tous, et tester la position image genre if (this.currentFrame == 10) {....} ?? parce que là, je galère ..

    JoãoCésar17023019
    Community Expert
    Community Expert
    July 23, 2018

    Hi.

    I'm not sure of what you want. I think the automatic translation isn't helping me here.

    Do you want to check the current frame of a Movie Clip using JavaScript? And if so, what you want to happen?

    Because your syntax is correct.

    if (this.currentFrame == 10)

    {

        // do something

    }

    Alama.be
    Known Participant
    July 23, 2018

    I use animate for create html5/oam animations files for integrate in muse because muse is buged and have somes mal functions. But yes it'work, I made a mistake of syntax
    Thanks JoaCésar and sorry for my bad English..

    Colin Holgate
    Colin HolgateCorrect answer
    Inspiring
    June 28, 2016

    this.gotoAndPlay(20);

    Note that although you see the timeline going from 1 to 40, in Javascript the frames count from zero. If you want to jump back to the frame with 20 by it, that would be this in Javascript:

    this.gotoAndPlay(19);

    Known Participant
    June 29, 2016

    That worked great, thanks!

    The "old" Flash was a bit more complete when it came to getting suggestion for codesnippets in the behavior pallette.

    Can I get the same thing in Animate CC for javascript and maybe download some extra snippets?

    Or is there any easy tutorial on how to get to understand javascript used on for instance objects and timelines?

    Colin Holgate
    Inspiring
    June 29, 2016

    The Code Snippets panel does include examples for both html5 canvas and html5 webgl.

    HTML5 Canvas is using CreateJS, and there are a lot of resources for that online.