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

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support