3

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

ketan
  • 19,129
  • 42
  • 60
  • 98
Mansuro
  • 4,558
  • 4
  • 36
  • 76

2 Answers2

1

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.

kapex
  • 28,903
  • 6
  • 107
  • 121
0

The problem is that interfaces, by design, only specify the signature for public functions, whereas the function in Checkbox is set as protected.

The only solutions:

  • remove the interface/Checkbox class from CellCheckBoxItemRenderer
  • remove the declaration from the interface
  • change Checkbox so hovered is a public property
  • it might be possible to change the accessor dynamically using the as3 commons bytecode project (http://www.as3commons.org/as3-commons-bytecode/emit.html), but I'm not 100% sure.
divillysausages
  • 7,883
  • 3
  • 25
  • 39