I have a problem performance issue with Flex MX StyleManager. I am implementing theme support and I run the setStyleDeclaration for about 340 different styles
for ( var i:int =1 ; i<whiteStyles.lenght; i++ )
{
view.styleManager.setStyleDeclaration(whiteStyles[i], view.styleManager.getStyleDeclaration(String(whiteStyles[i]).substr(String(whiteStyles[i]).lastIndexOf(".")) +"_blue"), false)
}
view.styleManager.setStyleDeclaration(whiteStyles[0], view.styleManager.getStyleDeclaration(whiteStyles[0]+"_blue"), true)
It take about 2 seconds for the UI update the first time I call the function as I call the function the time it takes to apply grows reaching 30+ second. I tried clearing the styles before but it dose not work. Any tips on how to improve this?
setStyleDeclaration is expensive. No way around that. You properly used the 'update' flag.
My guess for the increased runtime (going from 2 seconds to 30 seconds) is that for the first call, not many components exist yet. For subsequent calls, probably more components have been created and it takes longer to go through them (all components are updated even if not on the display list). If this is the case, then the only solution is to reduce the overall number of components created, maybe by re-using them.