多按钮事件闭包解决方案

var win = new Window(
    palette { \
    A: Button { text: '0' }, \
    B: Button { text: '1' }, \
    C: Button { text: '2' }, \
    D: Button { text: '3' }, \
    E: Button { text: '4' }, \
    F: Button { text: '5' }, \
    G: Button { text: '6' }, \
    H: Button { text: '7' }, \
    I: Button { text: '8' }, \
    J: Button { text: '9' } \
  }
);

win.show();

function attachButtonsEvent(index) {
    return function () {
        alert(index);
    };
}

for (var i = 0, l = win.children.length; i < l; i++) {
    win.children[i].onClick = attachButtonsEvent(i);
}

给TA充电
共{{data.count}}人
人已充电
AE开发PS/PR/AI脚本脚本开发

【PS脚本】设置图层标记颜色

2021-7-14 22:56:35

AE开发编程脚本开发

ScriptUI垂直居中CheckBox的四种方法

2021-7-14 23:15:59

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
今日签到
搜索