After conducting a detailed code review on my Mac, I’ve identified the part that causes this error.
The tool is generally used to generate end cards for specified networks, and the issue only occurs with the ‘minegral’ network. Mintegral, unlike other networks, includes a ‘disclaimer’, which results in an extra method being invoked during the process. Below, I am sharing the problem that is additionally called for this specific situation and causing the bug
function setDisclaimerType(geo)
{
if(!mintegralCheckBox.value) return;
var disclaimerLayer = getDisclaimerLayer();
// Error occurs right in the setDisclaimerLanguageType() method
setDisclaimerLanguageType(geo,disclaimerLayer);
disclaimerLayer = getDisclaimer320x50Layer();
setDisclaimerLanguageType(geo,disclaimerLayer);
disclaimerLayer = getDisclaimer640x120Layer();
setDisclaimerLanguageType(geo,disclaimerLayer);
}
The error is occurring specifically at the setDisclaimerLanguageType(geo, disclaimerLayer)
line. There doesn’t appear to be any issues with the geo
and disclaimerLayer
parameters; they are being passed to the method as intended.
function setDisclaimerLanguageType(geo,disclaimerLayer)
{
// Error occurs in openSmartObject(disclaimerLayer) method
openSmartObject(disclaimerLayer);
var targetBadgeName = "disclaimer_";
targetBadgeName += geo;
var isBadgeFound = false;
for(var i=0; i< app.activeDocument.layers.length;i++)
{
var targetLayer = app.activeDocument.layers[i];
targetLayer.visible = (targetLayer.name === targetBadgeName);
if(targetLayer.name === targetBadgeName) isBadgeFound = true;
}
if(!isBadgeFound)
{
var defaultBadge = findLayerByName("disclaimer_US");
defaultBadge.visible = true;
}
closeAndSaveSmartObject();
}
The source of the error is coming from the line ‘openSmartObject(disclaimerLayer);’. This method is responsible for opening the smart object and activating the layer related to the target language required for setting the disclaimer.
function openSmartObject(targetLayer)
{
var doc = app.activeDocument;
doc.activeLayer = targetLayer;
app.activeDocument.suspendHistory("Edit Smart Object", "editSmartObject()");
}
function editSmartObject() {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), >charIDToTypeID('Trgt'));
desc.putReference(charIDToTypeID('null'), ref);
executeAction(stringIDToTypeID('placedLayerEditContents'), desc, >DialogModes.NO);
}
function closeAndSaveSmartObject()
{
app.activeDocument.save();
app.activeDocument.close(SaveOptions.SAVECHANGES);
}
Here, you can find the methods for opening and closing the Smart Object that is targeted.
The strange part is that I use the same methods to set up the ‘GooglePlayBadge’ Smart Object for other networks, and I don’t encounter any issues. The exact same methods work perfectly for the GooglePlayBadge used for all network options, both on Windows and macOS. However, it’s only the ‘Disclaimer’ used for a single network that doesn’t work on macOS. What do you think could be the reason for this?
The strangest part of and the reminder is this: I still don’t think there is any problem with the extendScript code directly. If you run the same extendScript-based script from “File>Script>EXTENDSCRIPT_NAME”, the code works flawlessly on Mac as well.
If there is anything that is unclear and you need more information, please let me know. And thank you for replying my question! ^^
@Erin_Finnegan