1

当我有超过 1 个时,我遇到了自定义事件的问题。

目前我有 2 个自定义事件:

  1. 导航事件
  2. 好友动作事件

它们都与以下内容几乎相同:

package events
{
import starling.events.Event;

public class NavigationEvent extends Event
{
    public static const SHOWSCREEN:String = "";
    public var params:Object;

    public function NavigationEvent(type:String, _params:Object = null, bubbles:Boolean=false, data:Object=null)
    {
        super(type, bubbles, data);
        this.params = _params;
    }
}
}

然而另一个是

public class FriendActionEvent extends Event

在主课上,我有 2 个听众

this.addEventListener(events.NavigationEvent.SHOWSCREEN, onNavigationScreen);
this.addEventListener(events.FriendActionEvent.ACTION, onFriendAction);

和方法但是当我添加第二个监听器时我得到了错误

TypeError: Error #1034: Type Coercion failed: cannot convert events::NavigationEvent@fe5ee21 to events.FriendActionEvent.

所以我猜测 2 个自定义事件存在问题,但不确定如何解决。

干杯

4

1 回答 1

0

我认为onNavigationScreen正在接受FriendActionEvent参数(可能是来自其他事件处理程序的错误复制粘贴的情况)。

于 2013-07-03T07:59:46.260 回答