Share on Google+Share on Google+

Local style sheets in Flex4

Ads
You can set the style of components in tag. You can make a class and set the properties in it.

Local style sheets in Flex4:

You can set the style of components in <fx:Style> tag. You can make a class and set the properties in it. The syntax is following:

<fx:Style>
@namespace namespace_identifiernamespace_string;
selector_name {
style_property: value;
[...]
}
</fx:Style>

You will call the class in component by using styleName property.

Example:

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

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx"

minWidth="955" minHeight="600">

<!-- Local style-->

<fx:Style>

@namespace s "library://ns.adobe.com/flex/spark";

@namespace mx "library://ns.adobe.com/flex/mx";

.button{

font-family:"Verdana";

font-size:16px;

text-align:center;

color:#990000;

font-weight:bold;

button-width:100px;

button-height:50px;

}

.label{

font-family:"Verdana";

font-size:12px;

color:Green;

}

</fx:Style>

<s:Panel title="Local Style Example" width="288" height="182">

<s:Button id="btn"

label="Submit"

styleName="button"

x="85" y="31"/>

<s:Label text="This is a Local style example."

x="34" y="84"

styleName="label"/>

</s:Panel>

</s:Application>

Output:

Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Download this code

Advertisements

Posted on: June 21, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Ads

Advertisement