Customised status message for Alert control

22 01 2008

If you want to give customized status message {It will be shown on top-right instead of bottom-left} in an Alert window, you need to define the custom properties in a style tag.

<?xml version="1.0" encoding="utf-8"?>

<!-- giving colored status message of an alert control-->

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
	layout="absolute"
	width="320"
	height="240"
	backgroundGradientColors="[#ffffff, #b0b0ff]"
	>

	<mx:Style>
		@font-face{
			src: local("Comic Sans MS");
			fontFamily: customFont;
		}
		Alert{
			statusStyleName: customStatus;
		}
		.customStatus{
			/*Here color as well as font properties are changed.*/
			color: #FF0000;
			fontFamily: customFont;
			fontSize: 15;
		}
	</mx:Style>

	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;

			private var _alert:Alert

			private function showAlert():void{
				_alert = Alert.show("The Alert message goes here","Alert title.");

				_alert.status = "Status message";//status message!
			}
		]]>
	</mx:Script>

	<mx:Button label="Show Alert" y="116" x="109" click="showAlert()"/>

</mx:Application>




Giving same/different color for border & background of Flex Alert control

21 01 2008
<?xml version="1.0" encoding="utf-8"?>

<!-- giving colors to the text, border & background of an alert control-->

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
	layout="absolute"
	width="320"
	height="240"
	backgroundGradientColors="[#ffffff, #b0b0ff]"
	>

	<mx:Style>
		Alert{
			/*Change this to give different background colors
			{where the alert message is displayed}
			backgroundColor: #ffffff;*/

			backgroundColor: #b0b0ff;
			borderColor: #b0b0ff;
			color: #000000;
		}
	</mx:Style>

	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;

			private var _alert:Alert;

			private function showAlert():void{
				_alert = Alert.show("The Alert message goes here","The Alert title goes here");
			}
		]]>
	</mx:Script>

	<mx:Button label="Show Alert" click="showAlert()" x="116" y="109"/>

</mx:Application>