Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi.
There is.
Please check out this example:
adobe/animate cc/html5_canvas/switch_button at master · joao-cesar/adobe (github.com)
The code / JS to create the button interactivity is the following (placed in the main timeline):
this.makeSwitchButton = function(target, onLabel, offLabel)
{
if (!target.started)
{
target.stop();
target.toggled = false;
target.hit.on("click", function(e)
{
e.currentTarget.parent.toggled = !e.currentTarget.parent.toggled;
e.currentTarget.parent.gotoAndPlay(e.currentTarget.parent.toggled ? onLabel : offLabel);
});
target.started = true;
}
};
Then place this code inside the Movie Clip instance being used as a button:
exportRoot.makeSwitchButton(this, "yes", "no");
I hope this helps.
Regards,
JC
Copy link to clipboard
Copied
Thank you JC, I will pass this onto our programmer - I'm sure it will help!
Cheers, Graham
Copy link to clipboard
Copied
You're welcome!
Please let us know if you need further help.
Regards,
JC