Search code examples
actionscript-3apache-flexflex4.5flex-spark

Super interface and super class having the same method name


I am trying to create a spark datagrid item renderer. This item renderer extends a checkbox, and implements IGridItemRenderer

public class CellCheckBoxItemRenderer extends CheckBox implements IGridItemRenderer

When I implement IGridItemRenderer, I need to implement the interface methods, I am having a problem with the following methods:

public function get hovered():Boolean
{
}

public function set hovered(value:Boolean):void
{
}

since the methods are inherited as well from the checkbox

EDIT The signatures of the functions

//spark checkbox signature
protected function get hovered():Boolean
protected function set hovered(value:Boolean):void

and the signature above belongs to the interface IGridItemRenderer


Solution

  • I guess the implementation of IGridItemRenderer is the more important part, so you can use it in a datagrid. The CheckBox provides just the functionality, you don't have to extend it if there are conflicts in my opinion.

    public class CellCheckBoxItemRenderer implements IGridItemRenderer {
    
        private var checkBox:CheckBox;
    
        public function getCheckBox {
            return checkBox;
        }
    
        //...
    }
    

    If CheckBox would implement any useful interfaces, you could also implement them in your renderer and delegate the methods to the checkbox, which may let you encapsulate the whole checkbox. That's not the case here though.