Home Tutorial Flex Flex4 Components External style sheets in Flex4

 
 

External style sheets in Flex4
Posted on: June 21, 2010 at 12:00 AM
In this example you can see how we can use external style sheet.

External style sheets in Flex4:

In this example you can see how we can use external style sheet. You can choose a CSS file and set the properties of components in it. After that you call this style sheet in to main application.

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">

<!-- call external style sheet using source property-->

<fx:Style source="externalstyle.css"/>

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

<s:Button id="btn"

label="Submit"

styleName="button"

x="103" y="28"/>

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

x="22" y="84"

styleName="label"/>

</s:Panel>

</s:Application>

externalstyle.css

/* CSS file */

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

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

.button{

font-family:"Verdana";

font-size:14px;

text-align:center;

color:#990000;

font-weight:bold;

}

.label{

font-family:"Verdana";

font-size:14px;

font-weight:bold;

color:blue;

}

Output:

Running Application:

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

Download this code

Download externalstyle.css file code

Related Tags for External style sheets in Flex4:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.