actionscript behind mxml component properties

I was wondering how Flex implements certain properties in components that can be declared in the mxml but don’t show up in the ActionScript properties. For example, you can set the background color on a VBox in mxml but there is no corresponding backgroundColor in either the direct or inherited properties of VBox:

<mx:VBox width=”100%” backgroundColor=”#ffff80″ horizontalAlign=”center”>

My first guess was that this was being accomplished using CSS styles behind the scenes, so I set the -keep-generated-actionscript property on the compiler to be able to see the actual AS code that my application is writing to generate the mxml.

Here’s an excerpt of what I found:

propertiesFactory: function():Object { return {
childDescriptors: [
new mx.core.UIComponentDescriptor({
type: mx.containers.VBox
stylesFactory: function():void {
this.backgroundColor = 16777088;
this.horizontalAlign = “center”;

Ah, so it does look like CSS after all… ‘stylesFactory’… but that code isn’t terribly easy on my eyes!

So I guess the way to set something like the background color of a VBox on the fly in your AS code would be to use something like the styleName property of the component…

This entry was posted in ActionScript, Flex by Fuad Kamal. Bookmark the permalink.

About Fuad Kamal

With a background in biotechnology, Fuad began his career developing assays and cutting edge technologies around HIV research. From there he shifted into the bioinformatics arena, where he developed innovative information systems in Perl. He started playing with the Flash platform around the time Flash 4 was released, and later developed the flash interface for the Flight Information Display System (FIDS) that you see at pretty much every major airport around the world today. Fuad loves delving into new technologies and pushing technologies in novel directions. Fuad has pursued the study of several martial arts over the years. Recently he received second dan in Taekwon Do while concurrently studying Iaido under Doshu Shiro Shintaku. Fuad has often applied principals he learned from his study of the martial arts to mentoring others as well as taking a unique approach to problem solving. He has found that quite often, the barriers we set before us are more mental than anything else, and the key to overcoming them lies in understanding this concept.

Leave a Reply