Copy link to clipboard
Copied
Hi all,
Say we have a table of contents HTML page. If each chapter is a different HTML page with a number of anchored sections, the table of contents will list anchor links like <a href="chapitre_3.html#section5-2">.
Now let us suppose that a chapter is an Animate CC timeline with a number of labelled sections ("section5-2" for example). Is there a way I could pass parameter "section5-2" from the table of contents HTML page, so that after loading the correct HTML page containing the HTML5 canvas publishing of the chapter, I could run a this.gotoAndStop("section5-2") ? Any ideas ? Thanks in advance
Copy link to clipboard
Copied
Try reading window.location, to see if it includes the anchor part. If it does you could use window.location.split( "#" ); to get an array, probably of length 2. Which means this single line might work:
this.gotoAndStop(window.location.split( "#" )[1]);
Copy link to clipboard
Copied
Thank you very much, Colin. It works like a charm adding a toString() call (code on frame 1) :
var section = window.location.toString().split( "#" )[1];
Strangely, though frame 1 is indeed labelled section3-1, calling this.gotoAndStop( section) when (section == "section3-1") produces an empty canvas ! So I need the following test (or leaving anchor #section3-1 for the first link) :
if (section == "section3-1")
{
this.stop();
}
else
{
this.gotoAndStop( section);
}
Copy link to clipboard
Copied
I have seen similar issues. It seems that telling CreateJS to gotoAndStop to the frame it's already on can cause problems.