1
我有自定義事件的問題時,我有超過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::[email protected] to events.FriendActionEvent.
所以我猜測有2個自定義事件存在問題,但不確定如何解決它。
乾杯
和空字符串作爲事件的名稱可能導致此錯誤,以防兩個自定義事件具有相同的空名稱) – fsbmain
那麼我應該重命名所有參數爲獨特的東西嗎?我會試試 – puks1978
空字符串是問題。 – puks1978