StyleManager class in Flex allows you to easily read and write individual style properties from the comfort of your AS3 code.
But it’s not as easy as it could be.
You still have to retrieve each style declaration, make sure they exist, and then either return or set the desired style property. It’s not a lot of work, but it’s repetitive, and we can do better.
StyleUtil is an all-static class I created with methods to access and modify individual style properties.
There are two basic methods,
getCSSStyle(), as well as
hexToString() methods for converting hexadecimal values.
Now, changing the background color of a
Canvas container is as simple as calling:
Not too shabby, eh?
Full source code is available here:
As well as a few sample getters and setters: