Hi.
You can use the labels array property that stores the labels names and their corresponding frames. Then you can increment and decrement a counter variable to keep track of which array item to access. Like this:
Preview:
https://bit.ly/2XQr6Po
JavaScript code:
var root = this;
var labels = root.labels;
var index = 0;
root.start = function()
{
root.gotoPrevLabel = function(e)
{
index = root.clamp(--index, 0, labels.length - 1);
root.gotoAndStop(labels[index].position);
};
root.gotoNextLabel = function(e)
{
index = root.clamp(++index, 0, labels.length - 1);
root.gotoAndStop(labels[index].position);
};
root.on("click", function(e)
{
if (e.target.name === "prevButton")
root.gotoPrevLabel();
else if (e.target.name === "nextButton")
root.gotoNextLabel();
});
root.stop();
};
root.clamp = function(value, min, max)
{
if (value < min)
return min;
if (value > max)
return max;
return value;
};
if (!root.frame0Started)
{
root.start();
root.frame0Started = true;
}
FLA / source / files:
https://github.com/joao-cesar/adobe/tree/master/animate%20cc/html5_canvas/navigate_from_label_to_label
I hope this helps.
Regards,
JC