Copy link to clipboard
Copied
Hello everyone.
I have some code that looks like this:
var TheButton = ThePage.buttons.add({geometricBounds:[Top, Lef, Bot, Rgt], opacity: .2, name:"EMailButton" + n}); | ||
with(TheButton) | ||
{ | ||
bottomLeftCornerOption = CornerOptions.ROUNDED_CORNER; | ||
bottomRightCornerOption = CornerOptions.ROUNDED_CORNER; | ||
topLeftCornerOption | = CornerOptions.ROUNDED_CORNER; | |
topRightCornerOption | = CornerOptions.ROUNDED_CORNER; | |
name = EMailList | ||
label = EMailList | ||
fillColor = gButtonFillColor; | ||
opacity = 20; | ||
} |
Theh problem is in the final line. I am trying to adjust the opacity of the fill in this object but the method I am using is not working. I have looked all over for the correct syntax for adjusting the fill color opacity and I cannot find an example of code, nor does the documentation seem to address this issue,
Can anyone tell me how to adjust my opacity or tell me where to look for finding out that information?
I would greatly appreciate any help this forum could give me.
R,
John
@John – here just an example for adding one button with transparency set to 20% in every state with some of your properties. Others set to distinct values so that this example will work:
...//Just an example:
var myButtonGeoBounds = [0,0,10,50];
var myFillColor = "Magenta";
var myButtonProperties = {
geometricBounds: myButtonGeoBounds,
name:"EMailButton",
label:"EMailButton",
bottomLeftCornerOption:CornerOptions.ROUNDED_CORNER,
bottomRightCornerOption:CornerOptions.ROUNDED_CORNER,
to
Copy link to clipboard
Copied
Hi,
use in this line:
//...
fillTransparencySettings.blendingSettings.opacity = 20;
//...
Jarek
Copy link to clipboard
Copied
Hello Jarek. Thanks for yur reply.
I have been using this code to create the buttons:
for(var n = 0; n < EMailCount; n++) | ||
{ | ||
var TheButton = ThePage.buttons.add({geometricBounds:[Top, Lef, Bot, Rgt], name:"EMailButton" + n}); | ||
with(TheButton) | ||
{ | ||
bottomLeftCornerOption = CornerOptions.ROUNDED_CORNER; | ||
bottomRightCornerOption = CornerOptions.ROUNDED_CORNER; | ||
topLeftCornerOption | = CornerOptions.ROUNDED_CORNER; | |
topRightCornerOption | = CornerOptions.ROUNDED_CORNER; | |
name = EMailList | ||
label = EMailList | ||
fillColor = gButtonFillColor; // Makes the fill ccolor RGB 255,0,0, | ||
fillTransparencySettings.blendingSettings.opacity = 90; | ||
//contentTransparencySettings.blendingSettings.opacity = 90; | ||
//transparencySettings.blendingSettings.opacity = 90; | ||
} |
Please note that I have tried fillTransparencySettings. contentTransparencySettings and transparencySettings, each by themselves and all three together and it has made no difference. The fill color remains as ruby red as a bowl of cherries.
So I am still doing something wrong.
R,
John
Copy link to clipboard
Copied
Hi,
right,
this line could goes like this:
groups[0].rectangles[0].fillTransparencySettings.blendingSettings.opacity = 20;
button is more complex object than regular ones...
Jarek
Copy link to clipboard
Copied
I would just apply an object style which works on buttons and will apply the opacity correctly.
I don't know why you can set the opacity of a button directly, it smell of a bug to me and if someone is feeling saintly they can report it.
Trevor
Copy link to clipboard
Copied
@Trevor – yes. Sounds like a bug. But after inspecting the issue, I think there is no bug.
Let's skin a Button object a bit:
A button consists of one or up to three state objects.
Every state object cannot exist without having at least one group object that would itself consist at least of one pageItem.
If we inspect the first group item of the first state of a selected button where transparency is applied through the UI (example: Opacity 20%) we get the following result:
app.selection[0].states[0].groups[0].transparencySettings.blendingSettings.opacity;
//Result 20
Uwe
Copy link to clipboard
Copied
Just to demonstrate my case here some screen grabs:
1. Setting opacity through the UI:
2. Setting opacity through script (before script)
3. Setting opacity through script (after script)
Script:
app.selection[0].states[0].groups[0].transparencySettings.blendingSettings.opacity = 20;
Uwe
Copy link to clipboard
Copied
@John – here just an example for adding one button with transparency set to 20% in every state with some of your properties. Others set to distinct values so that this example will work:
//Just an example:
var myButtonGeoBounds = [0,0,10,50];
var myFillColor = "Magenta";
var myButtonProperties = {
geometricBounds: myButtonGeoBounds,
name:"EMailButton",
label:"EMailButton",
bottomLeftCornerOption:CornerOptions.ROUNDED_CORNER,
bottomRightCornerOption:CornerOptions.ROUNDED_CORNER,
topLeftCornerOption:CornerOptions.ROUNDED_CORNER,
topRightCornerOption:CornerOptions.ROUNDED_CORNER,
fillColor: myFillColor
};
var myNewButton = app.documents[0].pages[0].buttons.add();
myNewButton.properties = myButtonProperties;
//In case your new button will have different states and all states should have a opacity of 20%:
for(var n=0;n<myNewButton.states.length;n++){
myNewButton.states
.groups[0].transparencySettings.blendingSettings.opacity = 20; };
Uwe
Copy link to clipboard
Copied
good explanation Uwe
Copy link to clipboard
Copied
@Uwe,
...valuable one!
Jarek
Copy link to clipboard
Copied
My many thanks to all of you for sticking with me. Uwe, your solution works like a dream and I greatly appreciate your help. Is that two lunches I now owe you? (grin)
One final request before we close this conversation. Uwe, you mentioned the word "inspect" in your description of what should be. I have been looking for something like that for the last month or so and cannot find it though I know it must exist some place in some obscure tome about debugging Javascript. Can you point me to the documentation which tells me how to use it?
TIA!
John
Find more inspiration, events, and resources on the new Adobe Community
Explore Now