Today I was working on a Flex 3 application which I now want to compile using the Flex 4 SDK. One of the warnings that cropped up in the Flash Builder Problems panel was the following message:
3608: 'getStyleDeclaration' has been deprecated since 4.0. Please use 'IStyleManager2.getStyleDeclaration on a style manager instance'.

The line in question was the following which applies a global theme color after a color value has been loaded from a remote data source::

view plain
1StyleManager.getStyleDeclaration('global').setStyle('themeColor', '0x'+gradient_to);

It took me some time to figure out what the heck the 'use IStyleManager2.getStyleDeclaration on a style manager instance' actually meant... it was by no means a straight forward warning. After some Googling and trial and error I came up with this which seems to do the job:

view plain
1var cssDeclaration:CSSStyleDeclaration = FlexGlobals.topLevelApplication.styleManager.getStyleDeclaration('global');
2cssDeclaration.setStyle('themeColor', '0x'+gradient_to);

I'm not sure if this is the correct and/or best way to achieve the same thing but it appears to work which generally is good enough for my requirements :-)
Hope this helps someone, please leave feedback and corrections where applicable.