본문 바로가기

Blog/Flex

Migrating to Flex 4, StyleManager

I haven't seen this well documented before, but if you're component was using the style manager and is throwing a bunch of warnings in Flex 4, you need to get the "global" style manager now. You probably see this error:
"3608: 'getStyleDeclaration' has been deprecated since 4.0. Please use 'IStyleManager2.getStyleDeclaration on a style manager instance'."

This is really easy to fix, but not extremely well documented. StyleManager is no longer a global singleton, but there is an instance of it running already at the top of your app. Flex 4 has a new static class called FlexGlobals. You can use that to get a reference to the top of your app and then get the instantiated one.

//Flex 3 code
StyleManager.getStyleDeclaration("someStyle");
//Flex 4 code
FlexGlobals.topLevelApplication.styleManager.getStyleDeclaration("someStyle");

출처 : http://www.jonathanrowny.com/journal/migrating-flex-4-stylemanager