Migrating to Flex 4, StyleManager
Submitted by jrowny on Fri, 03/05/2010 - 11:08
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");
Bookmark/Search this post with:
good
Submitted by pete (not verified) on Thu, 09/02/2010 - 04:37.It's really annoying all those flex variable changes. I got this error today and thanks to this article i could solve it. It is the same kind of the toplevelapplication one.
But in fact, the new flex 4 framework is better, when you solve these "minor" changes....
If anyone is interested in full migration from 3 to 4, i found another article too that is a good starting point:
http://jaumemussons.wordpress.com/2010/08/31/migrate-from-flex-3-to-flex...
Awesome
Submitted by Tony Alves (not verified) on Thu, 08/05/2010 - 12:43.Finally! An answer to what happened to StyleManager.
Thanks so much for this solution. The message should have this in the note that displays that it has been depricated.
This little deprecated method
Submitted by Shawn Yale (not verified) on Tue, 07/20/2010 - 10:18.This little deprecated method error was irritating. Thanks for the post. you are right, there isn't a lot of documentation. Yours is the fastest. I found a couple others on using an instance of the IStylemanager2 class, but they seemed convoluted. Your method is very easy to implement.
Cheers!
Shawn
Or if your component extends
Submitted by Simon (not verified) on Wed, 07/14/2010 - 06:06.Or if your component extends UIComponent you can simply retrieve the StyleManager instance using the public getter within UIComponent.as: styleManager e.g. styleManager.getStyleDeclaration('.someDeclaration') and styleManager.getStyleDeclaration('.someDeclaration').getStyle('someStyle')
Cheers,
Simon