Past thoughts on ‘Flex’

Changing the modalTransparencyColor and other PopUp styles in Flex

Thursday, January 31st, 2008

I bumped into this problem a few weeks ago and couldn’t figure out how to solve: we have this application with multiple popups, most with a black overlay behind them. But one specifically needed a white overlay.

The settings for this overlay are usually inserted into the main MXML <mx:Application /> tag or with the global style selector, as in:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
	modalTransparency=".5"
	modalTransparencyBlur="0"
	modalTransparencyColor="#000000">
</mx:application>

or

<mx:Style>
	global {
		modalTransparencyBlur: 0;
		modalTransparency: .5;
		modalTransparencyColor: #000000;
	}
</mx:Style>

But those setting are kept for the entire application and there is no apparent way to change those at runtime.

Gladly I chose to ask at the great blog.flexexamples.com if anyone could help me, and the great peterd posted a whole set of explanations on how to do it. Thanks a lot peterd!

Basically you can access the global style settings and runtime through StyleManager.getStyleDeclaration("global") and then use setStyle() to change them.

You better check out the entire explanation over there.