ExamBase.as

protected function SetAnsHandler(a_event:Event=null):void
{
mc_submit.visible = true
SetLock(a_event.m_target);
}


Alpha.as extends ExamBase
override function SetAnsHandler(a_event:AlphaEvent):void
{
super.SetAnsHandler(a_event)
//something
}


出現error 1023: Incompatible override.

原因是丟進去的變數,屬性不同的關係。

查了一下資料和文章,發現原來override時,不允許丟進來的參數和父類別不相同
節錄一下help的文字:
To override an inherited method, you must use the override attribute 
and ensure that the name, number,
type of parameters, and the return type match exactly.


那如果要達到原本的需要,要朝向overload的方面去做,但as3又不支援overload。
所以有幾篇文章是教如何「模仿」overload的效果。

AS3笔记(8),关于方法重载
[转]AS3类 - 重载的实现

沒有留言: