Flex 不兼容覆盖,bug?
我正在编写 Flex DataGridColumn 类的扩展。我想覆盖可编辑和可排序的属性,以便我可以在设置器中调度事件。因此,我从 Adobe Docs 中查找了方法签名(我使用的是 Flex 3.5 编译器):
语言版本:ActionScript 3.0
实现
public function get editable():Boolean
public function set editable(value:Boolean):void
public var sortable:Boolean
我应该能够覆盖可编辑的 setter,并使用 setter 覆盖可排序的功能。
在我的代码中,我有:
public override function set editable(value:Boolean):void {
super.editable = value;
//code to dispatch event
}
但是
public override function set sortable(value:Boolean):void{
super.sortable = value;
//code for event
}
我收到 #1023 错误:不兼容的覆盖。我已经尝试了方法签名的各种组合,但这些组合与上面文档中的组合完全相同。
什么给?我错过了一些明显的东西吗?
编辑:显然文档与实际源代码不符。可编辑和可排序都是 DataGridColumn.as 中的变量。无论如何,我可以用 setter/getter 覆盖它们而不修改基类吗? DataGridColumn.as 来源:
public var editable:Boolean = true;
public var sortable:Booelan = true;
I'm writing an extension to the Flex DataGridColumn class. I want to override the editable and sortable properties so that I can dispatch an event in the setter. So I looked up the method signature from the Adobe Docs (I'm using Flex 3.5 compiler):
Language Version: ActionScript 3.0
Implementation
public function get editable():Boolean
public function set editable(value:Boolean):void
public var sortable:Boolean
I should be able to override both the setter for editable, and use a setter to override the functionality of sortable.
in my code I have:
public override function set editable(value:Boolean):void {
super.editable = value;
//code to dispatch event
}
and
public override function set sortable(value:Boolean):void{
super.sortable = value;
//code for event
}
However I get a #1023 error : Incompatible override. I've tried all sorts of combinations on the method signatures, but these are exactly the same as the ones in the docs above.
What gives? Am I missing something obvious?
EDIT: Apparently the documentation is not in line with the actual source code. Both editable and sortable are variables in DataGridColumn.as. Anyway I can override them with a setter/getter without modifying the base class?
DataGridColumn.as Source:
public var editable:Boolean = true;
public var sortable:Booelan = true;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能将变量重写为属性(获取/设置)。顺便说一句,
editable
和sortable
成为 SDK 4.0 中的属性。You cannot override variable as property(get/set). BTW,
editable
andsortable
became properties in SDK 4.0.