【问题标题】:AddEventListener for Click is not working with AS2.0 and Flash Player 10AddEventListener for Click 不适用于 AS2.0 和 Flash Player 10
【发布时间】:2012-01-11 12:26:22
【问题描述】:

我有来自Adobe的以下代码:

myListener = new Object();
myListener.click = function(evt){
    trace(evt.type + " triggered");
}
myButton.addEventListener("click", myListener);

但这不起作用,尽管舞台上的 btn 与代码中的实例名称相同。

【问题讨论】:

  • 您阅读的代码旨在与 Button 组件一起使用。您确定您使用的是组件(取自组件窗口)吗?

标签: flash actionscript actionscript-2 flash-cs5


【解决方案1】:

提供的代码仅适用于实际的按钮组件。按钮 symbol 不会调度 click 事件并且没有 addEventListener 方法。您必须将代码更改为:

myButton.onRelease = function() {
    trace("click triggered");
}

【讨论】:

  • 感谢这仅适用于 Button 组件。知道如何将事件侦听器添加到按钮符号。或者有什么方法可以在代码中实例化按钮组件?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-03-13
  • 2014-08-20
  • 2011-03-02
  • 2012-09-20
  • 2010-10-30
  • 2012-06-10
  • 2010-10-15
相关资源
最近更新 更多