« Debug/Logging Client-Side - Part 2
» CAPTCHA in Flex - Main Class

ActionScript, Flex 2, MXML

Add CSS style to a component

Stelian Crisan | 30.10.07 | 1 Comment

This it’s a clean example about how to add a CSS style to a component in Flex.

We need to create the CSS file (style.css) and add a custom style:

.myStyle {
font-size: 20px;
color: #cc0000;
}

Make a new Flex project and in the defalul MXML aplication file add this code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
	layout="absolute" >
 
<!--// Here we call our CSS file into the project -->
	<mx:Style source="style.css"/>  
 
 
<!--// This is a simple Text  component -->
	<mx:Text 
		x="50" y="50" 
		width="300" height="100"
		text="This is a simple Text component 
			with style set up in a CSS file" 
		styleName="myStyle" />
 
</mx:Application>

Also we can use ActionScript to add styles to components:

var _tmpLabel:Label = new Label();
_tmpLabel.text = "Here you can add your text.";
_tmpLabel.setActualSize(300,100);
_tmpLabel.styleName = "myStyle";

Popularity: 36%

Share and Enjoy:
  • Technorati
  • StumbleUpon
  • del.icio.us
  • NewsVine
  • Reddit
  • Digg
  • Furl
  • co.mments
  • blogmarks
  • Slashdot
  • DZone
  • Taggly
  • YahooMyWeb
  • connotea
  • Webride




Tags: , , , , ,

This post was written by Stelian Crisan

Views: 2132

related

popular

1 Comment

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

:

:


« Debug/Logging Client-Side - Part 2
» CAPTCHA in Flex - Main Class