Styling Semantic Components

From TechWiki

Jump to: navigation, search

Semantic components are standard Flash objects (movies) and therefore can be styled and modified as with any other Flash component.

Contents

General Resources

General Approach

As with any general application language, there are an infinite number of ways to build Flash applications. Since this is just a basic guide, we will stick with approaches suitable for only simple applications or modifications.

The standard components of a Flash application are represented by configurations and settings (*.xml), ActionScript files (for business logic and events handling, see *.as), applications and user interface components (*.mxml), and optional style sheets (*.css, but a restricted subset) images and data. ActionScript (or, indeed, many scripts such as HTML or PHP) can also be embedded in script sections in MXML files.

Since most UI and app-level changes occur in the MXML files, we will concentrate on those for these styling instructions.

Overview of MXML

MXML is obviously an XML-based syntax. This guide assumes a basic familiarity with that syntax.

MXML objects are applications, containers or controls, and may have properties, events or bindings. Each object has a specified set of behaviors and properties; these are inherited from their parents. Component properites are set in a very similar manner to what is familiar with CSS or HTML. A given object may use its specifically identified properties, or those of its parental objects.

Some Basic Tutorials

Property Inheritance

All sComponents inherit property specifications from their parent objects. These inheritance paths are shown below for the various sComponents, with the object providing the richest set of available properties shown in Bold. For the standard Flash controls, the normal root parent is UIComponent. For standard Flash containers, the normal root parent is Container.

Styling HTML

Flash only has limited support for styling HTML within a htmlText area. You can do fonts, classes, and underlines for links and hovers. There are a couple of useful tutorials, with the latter being somewhat better. There is also an example in the Adobe Flex 3 help guide; make sure to scroll to the comments.

Some Styling Tips

  • Applications have a gradient background; to create a solid background, look for code such as this:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="components.*"
  xmlns:semanticComponents="com.sd.semantic.components.*" layout="vertical" 
  creationComplete="init()" currentState="searchState" backgroundColor="#FFFFFF"
  backgroundGradientColors="[#FFFFFF, #FFFFFF]"
  • Spaces are handled strangely when using the htmlText area control; use the condenseWhite="true" property
  • To style labels differently than bound data values, use a construct such as the HBox component:
<semantic:sHBox paddingLeft="7" height="16" semanticDataProvider="{data.semanticDataProvider}">
  <semantic:sHBox>
    <mx:Label text="Last updated:" fontWeight="bold" width="90" textAlign="right" />
    <semantic:sText text="cosmo_updateDate" semanticDataProvider="{data.semanticDataProvider}"/>	
  </semantic:sHBox>
</semantic:sHBox>
Personal tools