Fx{r} is trying to start the Fx{r} Community! Please join our group on Adobe Groups following this link: http://groups.adobe.com/groups/ab29539ab9.
Fx{r} is now on Twitter too. Follow us @ twitter.com/fx_r!
«
»

ActionScript, Flex 2, MXML

Add CSS style to a component

Stelian Crisan | 30.10.07 | 1 Comment

Google Buzz

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";
Share and Enjoy:
  • Twitter
  • Google Buzz
  • LinkedIn
  • Google Bookmarks
  • del.icio.us
  • Digg
  • Sphinn
  • blogmarks
  • Reddit
  • StumbleUpon
  • Facebook
  • DZone
  • FriendFeed
  • Yahoo! Buzz
  • Yahoo! Bookmarks
  • Slashdot
  • MySpace
  • Add to favorites




Tags: , , , , ,

This post was written by Stelian Crisan

Views: 6984

related

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> <pre lang="" line="" escaped="">

:

:


«
»