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

Adjust Alpha by shortcut keys, with JSFL-command code

Explorer ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

Hello everyone,

 

I am in the process of getting my shortcuts right, as I was used to in the Flash era. I used to have a workflow where I could adjust objects (symbols, fills, lines, etc) on the canvas step by step.
This was in terms of rotating, scaling and adjusting the alpha channel (-1%, -10%, + 1%, + 10%).

 

With the alpha channel this was of course only possible if the object was a symbol.
The problem lies with the alpha channel. If I record my history while editing the alpha, the correct JSFL code will not come out and it will be useless.

 

With previous versions I had succeeded, however, not step by step. So then the command adjusted the symbol hard to 90% (instead of -10% per step). It would really benefit my workflow if this were possible.

 

Ideally one would like the commands:
- adjust alpha of symbol by -1% per step, shortcut: Ctrl-Alt- [
- adjust alpha of symbol by -10% per step, Shift-Ctrl-Alt- [
- adjust alpha of symbol by + 1% per step, Ctrl-Alt-]
- adjust alpha of symbol by + 10% per step, Shift-Ctrl-Alt-]

 

Hoping for clarification. Maybe in form of JSLF code that i can put in de commands folder of AnimateCC. Thanks!

Views

357

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

correct answers 1 Correct answer

Community Expert , May 19, 2021 May 19, 2021

Hi.

 

These scripts should help:

https://github.com/joao-cesar/adobe/tree/master/animate%20cc/jsfl/offset_alpha

 

OffsetAlphaBasis.jsfl code (for reference only):

var dom, selection;
var filePreffix = "OffsetAlphaBy";

function main(fileName)
{
	var offset;
	
	dom = fl.getDocumentDOM();
	
	if (!dom)
	{
		alert("Please open up a FLA first.");
		return;
	}
	
	selection = dom.selection;
	
	if (selection.length === 0 || selection[0].instanceType !== "symbol")
	{
		alert("Please select a symbol insta
...

Votes

Translate

Translate
Community Expert ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

Hi.

 

These scripts should help:

https://github.com/joao-cesar/adobe/tree/master/animate%20cc/jsfl/offset_alpha

 

OffsetAlphaBasis.jsfl code (for reference only):

var dom, selection;
var filePreffix = "OffsetAlphaBy";

function main(fileName)
{
	var offset;
	
	dom = fl.getDocumentDOM();
	
	if (!dom)
	{
		alert("Please open up a FLA first.");
		return;
	}
	
	selection = dom.selection;
	
	if (selection.length === 0 || selection[0].instanceType !== "symbol")
	{
		alert("Please select a symbol instance first.");
		return;
	}
	
	offset = parseInt(fileName.replace(filePreffix, ""));
	
	if (isNaN(offset))
	{
		alert("Offset is not a valid number.");
		return;
	}
	
	dom.setInstanceAlpha(clamp(0, selection[0].colorAlphaPercent + offset, 100));	
}

function clamp(min, value, max)
{
	if (value < min)
		return min;
	
	if (value > max)
		return max;
	
	return value
}

 

OffsetAlphaBy10.jsfl code (for reference only):

var scriptURI = fl.scriptURI;
var fileName = scriptURI.split("/").pop();
var baseScriptPath = scriptURI.replace(fileName, "") + "OffsetAlphaBasis.jsfl";

fl.runScript(baseScriptPath, "main", fileName);

 

The other scripts have the same code of the OffsetAlphaBy10.jsfl.

 

Except for the OffsetAlphaBasis.jsfl file, just assign the other ones to the desired shortcut.

 

One thing to notice here is that the offset value comes from the script name. So:

OffsetAlphaBy-10.jsfl will offset the alpha by -10;

OffsetAlphaBy-1.jsfl will offset the alpha by -1;

OffsetAlphaBy1.jsfl will offset the alpha by 1;

OffsetAlphaBy10.jsfl will offset the alpha by 10;

 

In this way you can assign other values if you need to. Just remember to place the OffsetAlphaBasis.jsfl file in the same directory of the other scripts.

 

One weird thing to notice is that the JSFL API doesn't have a proper way to get the alpha value of an instance... So what I did was to get the colorAlphaPercent property value to calculate the alpha. This is not a perfect solution but I hope it works in most cases.

 

I hope it 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
Explorer ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

LATEST

Hi @JoãoCésar ,

 

Thank you very much for the effort you have put into answering my question! I was away for a few days, hence the delay in my response.The code works perfectly and is exactly what I wanted.

 

I didn't quite understand what you meant by "the alpha value of an instance". Probably because I have not mastered the correct terminology of animate cc. What happens now is the following: I have a symbol (graphic or movieclip - Is that what you mean by instance?). Through your freshly written Commands I can now adjust the Color Effects > Alpha as desired. This is exactly what I wanted.

However, you indicate that there is a better method, so I am curious about that. At first I thought you meant by your comment that you would adjust the Color Effects > Advanced > Alpha and leave the values ​​of Red / green / blue untouched. In that case it would be a bit messy, but still useful. However, that is not the case and I can use this very well.

 

Thanks again!

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