Skip to main content
Participant
January 19, 2021
Answered

Playing the timeline from javascript

Hi all,

I'm currently trying to play the timeline from an animate project from it's parent webpage/document. I used ot be able to do this with edge animate by with a simple

 

sym.play();

 

I've checked through the posts on here and none of the solutions I've found seem to work for me. this.gotoAndPlay(0), just gives me a console error saying the function doesn't exist. Am I missing something obvious, the trigger I'm using to fire the function is working fine but I just can't seem toget the timeline to play.

 

Many thanks in advance.

This topic is closed to new replies. Start a new post to keep the conversation going.
kglad
kgladCorrect answer
Community Expert
January 19, 2021

you have a function in an animate fla canvas project, correct?

 

that function is being called by something somewhere (that probably lacks a reference to the "this" you want) and you've confirmed that function is being called, correct?

 

if so, in the same frame as that function add:

 

var _this=this;

 

and change your code to:

 

_this.gotoAndPlay(0).

7 replies

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 19, 2021

you have a function in an animate fla canvas project, correct?

 

that function is being called by something somewhere (that probably lacks a reference to the "this" you want) and you've confirmed that function is being called, correct?

 

if so, in the same frame as that function add:

 

var _this=this;

 

and change your code to:

 

_this.gotoAndPlay(0).

Translate
Participant
January 19, 2021

Thanks for the quick response!

 

I was putting the function( and the event listener) directly into the project.js file after publishing it. I didn't think to put it on the frame itself. That has worked!

 

Many thanks.

 

 

Translate
kglad
Community Expert
Community Expert
January 19, 2021

you're welcome.

Translate