I would like to implement check boxes inside flash list control using Flash Pro CS6. I literally follow example provided by Adobe at Work with a CellRenderer. The only code in my .fla file is:
myList.setStyle("cellRenderer", CustomCellRenderer);
myList.addItem({label:"Burger -- $5.95"});
myList.addItem({label:"Fries -- $1.95"});
and the only code in the CustomCellRenderer.as file is (copy-paste from the Adobe example):
package
{
import fl.controls.CheckBox;
import fl.controls.listClasses.ICellRenderer;
import fl.controls.listClasses.ListData;
public class CustomCellRenderer extends CheckBox implements ICellRenderer {
private var _listData:ListData;
private var _data:Object;
public function CustomCellRenderer() {
}
public function set data(d:Object):void {
_data = d;
label = d.label;
}
public function get data():Object {
return _data;
}
public function set listData(ld:ListData):void {
_listData = ld;
}
public function get listData():ListData {
return _listData;
}
}
}
When I test movie I get the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at fl.controls::CheckBox/drawLayout()
at fl.controls::LabelButton/draw()
at fl.core::UIComponent/drawNow()
at fl.controls::List/drawList()
at fl.controls::List/draw()
at fl.core::UIComponent/callLaterDispatcher()
Any help would be greatly appreciated. P.S. The author of similar question Display checkbox inside Flash List Control ? (Similar to item rendering in Flex) does not seem to have this problem - his problem is just in multiple selection functionality.
ANSWER (can not post answers for another 8 hour but eager to close the issue) Figured out myself: CheckBox component must be present in the library. Go to menu Window->Components-> Double click CheckBox. Check box will appear on the stage and in the library. Remove check box from the stage. Test movie.