Using constant in Flex CSS – with complie time error checking ?



s|TextArea{
 color:#eeeeee;
}

s|Button{
 color:#eeeeee; /* the same color as above*/
}
/* file: style\StyleConstants.as */
private const someColorConstant:uint = 0xff0000;
/* file: style\Style.css */
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";

s|TextArea{
 color:PropertyReference("someColorConstant");
}

s|Button{
 color:PropertyReference("someColorConstant");
}

 


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

<!-- // STYLE -->
 <fx:Style source="style/style.css" />
 <fx:Script>
 <![CDATA[
 include "style/StyleConstants.as";
 ]]>
 </fx:Script>
 <!-- // STYLE END -->

<s:Button x="10" y="10" label="Some button"/>
 <s:TextArea x="100" y="10" text="Some text"/>

</s:Application>


src : http://robertbak.com/wordpress/2011/10/using-constants-in-flex-css-with-compile-time-error-checking/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s