【发布时间】:2019-01-13 05:08:59
【问题描述】:
我当前的代码很糟糕,这是周五下午的特别节目:
if(layer.parent == doc && isLayerSet) {
//do something in this case fileNew.write('foo');
}
else if(layer.parent.parent == doc && isLayerSet) {
//do something in this case fileNew.write('foo');
}
else if(layer.parent.parent.parent == doc && isLayerSet) {
//do something in this case fileNew.write('foo');
}
else if(layer.parent.parent.parent.parent == doc && isLayerSet) {
//do something in this case fileNew.write('foo');
}
else if(layer.parent.parent.parent.parent.parent == doc && isLayerSet) {
//do something in this case fileNew.write('foo');
}
else if(layer.parent.parent.parent.parent.parent.parent == doc && isLayerSet)
{
//do something in this case fileNew.write('foo');
}
我这样做是作为概念验证,以查看脚本的其余部分是否有效(确实如此)。
游戏的目的是我想获得它的顶级父级(即文档的第一个子级)的名称。所有块都应该做同样的事情。
我知道有一种更简单的方法可以做到这一点,但是我对此还是很陌生,我不确定 javascript 和 Photoshop 的一些细微差别,所以任何帮助都将不胜感激!
【问题讨论】:
-
所有的块都一样吗?
//do something in this case fileNew.write('foo');? -
是的,很抱歉我没有提到这一点。我会修改它
标签: javascript scripting photoshop