Copy link to clipboard
Copied
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.
1 Correct answer
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).
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
Are you able to expand on what you did here and help? I have a simple html animated banner that must not play until a function in the HTML is called. So I have this on frame 1 to stop the timeline.
this.stop();
Then in HTML I have:
<script>
function timelineStart() {
console.log('please play the main timeline!');
this.play();
}
</script>
I can call the function timelineStart from Chrome Console and get the console log message please play the main timeline! and an error:
Uncaught TypeError: this.play is not a function at timelineStart
So function in HTML is working when I call it. But I cannot get the timeline to play when function is called. Are you able to help?
Copy link to clipboard
Copied
what's "this" reference in timelineStart?
Copy link to clipboard
Copied
'this' was my attempt to target the main timeline in Adobe Animate to play, from the HTML Just like 'this.stop();' on frame 1 in Adobe Animate which ovbviously works. I tried many variations including:
<script>
function timelineStart() {
console.log('please play the main timeline!');
play();
}
</script>
Copy link to clipboard
Copied
Ah, OK I've got it working in two ways. First I used stage.play();
In my HTML:
<script>
function timelineStart() {
console.log('please play the main timeline!');
stage.play();
};
</script>
Then I added a label in Adobe Animate 'start' and used exportRoot.gotoAndPlay("start");
<script>
function timelineStart() {
console.log('please play the main timeline!');
exportRoot.gotoAndPlay("start");
};
</script>

