Smooth action

Community Beginner ,
Dec 11, 2020 Dec 11, 2020

Copy link to clipboard

Copied

Hi there, my programmer has added a Yes/No slider item to a project but I think its action could be smoother as it switches from the Yes/No state. See attached MP4
Is there a way to do this?

Cheers, Graham

 

 

Views

54

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Dec 11, 2020 Dec 11, 2020

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

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 11, 2020 Dec 11, 2020

Copy link to clipboard

Copied

Thank you JC, I will pass this onto our programmer - I'm sure it will help!

Cheers, Graham

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Dec 11, 2020 Dec 11, 2020

Copy link to clipboard

Copied

You're welcome!

 

Please let us know if you need further help.

 

Regards,

JC

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines