External style sheets in Flex4


 

External style sheets in Flex4

In this example you can see how we can use external style sheet.

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

0

font-size:14px;

font-weight:bold;

color:blue;

1

}

Output:

Running Application:

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

2

Download this code

Download externalstyle.css file code

3

Ads