I'm using Flex SDK 4.6, very strange error occurs when i try to add spark checkbox on the stage:
var cb:CheckBox = new CheckBox();
optionsList.addElement(cb);
TypeError: Error #1009: Cannot access a property or method of a null object reference. at spark.skins.mobile::CheckBoxSkin/drawBackground()[E:\dev\4.y\frameworks\projects\mobiletheme\src\spark\skins\mobile\CheckBoxSkin.as:162] at spark.skins.mobile.supportClasses::MobileSkin/updateDisplayList()[E:\dev\4.y\frameworks\projects\mobiletheme\src\spark\skins\mobile\supportClasses\MobileSkin.as:313] at mx.core::UIComponent/validateDisplayList()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:8999] at mx.managers::LayoutManager/validateDisplayList()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:736] at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:819] at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1180]
When the chechbox is created in MXML there are no problems, but I need to create multiple instances in AS and than add them to stage.
Anyone have any clue what I'm doing wrong?
optionsList
is aList
component: List is not a container. You can't just add elements like that. You have to assign a custom ItemRenderer with a CheckBox. – RIAstar