Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Smooth action

Community Beginner ,
Dec 11, 2020 Dec 11, 2020

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

 

 

255
Translate
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 Expert ,
Dec 11, 2020 Dec 11, 2020

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

Translate
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

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

Cheers, Graham

Translate
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 Expert ,
Dec 11, 2020 Dec 11, 2020
LATEST

You're welcome!

 

Please let us know if you need further help.

 

Regards,

JC

Translate
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