Is overriding commitProperties neccessary when updating Spark components?
i understand when creating custom component, it's best practice defer property changes using setters/getters, setting "dirty" flag, calling invalidateproperties(), , letting commitproperties() handle actual changes.
but in case properties affect spark components, wouldn't redundant since spark components defer property changes?
for instance, have custom uicomponent contains spark button , want expose buttonlabel property changes label of button:
private var _buttonlabel:string;
private var mybtn:button;
private var _buttonlabelchanged:boolean = false;
function set buttonlabel(lbl:string){
_buttonlabel = lbl;
_buttonlabelchanged = true;
invalidateproperties();
}
so setting buttonlabel property trigger:
override protected function commitproperties(){
if(_buttonlabelchanged){
mybtn.label = _buttonlabel;
_buttonlabelchanged = false;
}
}
but setter "label" in spark button class using invalidation process makes above code pointless, yes? or missing something?
in components lifecycle, properties set before children created if tried access mybtn in setter null , error.
More discussions in Flex (Read Only)
adobe
Comments
Post a Comment