Styles in Apache Flex Applications

For applications developed in Apache Flex 3.x, Silk4J does not distinguish between styles and properties. As a result, styles are exposed as properties. However, with Apache Flex 4.x, all new Flex controls, which are prefixed with Spark, such as SparkButton, do not expose styles as properties. As a result, the GetProperty() and GetPropertyList() methods for Flex 4.x controls do not return styles, such as color or fontSize, but only properties, such as text and name.

The GetStyle(string styleName) method returns values of styles as a string. To find out which styles exist, refer to the Adobe help located at: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/package-detail.html.

If the style is not set, a StyleNotSetException occurs during playback.

For the Flex 3.x controls, such as FlexTree, you can use GetProperty() to retrieve styles. Or, you can use GetStyle(). Both the GetProperty() and GetStyle() methods work with Flex 3.x controls.

Calculating the Color Style

In Flex, the color is represented as number. It can be calculated using the following formula:
red*65536 + green*256 + blue

Example

In the following example, the script verifies whether the font size is 12. The number 16711680 calculates as 255*65536 + 0*256 + 0. This represents the color red, which the script verifies for the background color.
Assert.That(control.GetStyle("fontSize"), [Is].EqualTo("12"))
Assert.That(label.GetStyle("backgroundColor"), [Is].EqualTo("16711680"))