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

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

180

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 Expert ,
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

Votes

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

Votes

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

Copy link to clipboard

Copied

LATEST

You're welcome!

 

Please let us know if you need further help.

 

Regards,

JC

Votes

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