我正在尝试弄清楚为什么我的控制台.log命令在我将其放入单击事件时会抛出事件处理程序错误。
我的Javascript还不够好,不知道这是特定于Edge的,还是更全局的JS事物。
这是我的代码:
(function($, Edge, compId){
var Composition = Edge.Composition,
Symbol = Edge.Symbol; // aliases for commonly used Edge classes
//Edge symbol: 'stage'
(function(symbolName) {
Symbol.bindSymbolAction(compId, symbolName, "creationComplete", function(sym, e) {
// insert code to be run when the symbol is created here
var want = true;
console.log(want);
});
//Edge binding end
Symbol.bindElementAction(compId, symbolName, "${Rectangle}", "click", function(sym, e) {
// insert code for mouse click here
console.log(want);
});
//Edge binding end
})("stage");
//Edge symbol end:'stage'
})(window.jQuery || AdobeEdge.$, AdobeEdge, "EDGE-26284910");
创建后的第一个console.log
完成工作正常,单击事件中的下一个不起作用,我不知道为什么。谁能开导我?
谢谢
如果正确
缩进代码,您会注意到want
是在内部函数范围内定义的,无法从单击处理程序中访问。
(function($, Edge, compId){
var Composition = Edge.Composition,
Symbol = Edge.Symbol; // aliases for commonly used Edge classes
//Edge symbol: 'stage'
(function(symbolName) {
var want;
Symbol.bindSymbolAction(compId, symbolName, "creationComplete", function(sym, e) {
// insert code to be run when the symbol is created here
want = true; //you still can set its value
console.log(want);
});
//Edge binding end
Symbol.bindElementAction(compId, symbolName, "${Rectangle}", "click", function(sym, e) {
// insert code for mouse click here
console.log(want); // but now it is accessible from within this function
});
//Edge binding end
})("stage");
//Edge symbol end:'stage'
})(window.jQuery || AdobeEdge.$, AdobeEdge, "EDGE-26284910");