Styles in Apache Flex Applications

For applications developed in Apache Flex 3.x, Silk4NET 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 buttonBar in the Spark application uses font size 12.
 Imports SilkTest.Ntf.Flex

Public Module Main
    Dim _desktop As Desktop = Agent.Desktop
    
    Public Sub Main()
        Dim Application As SparkApplication
        Dim ButtonBar As SparkButtonBar
        Application = _desktop.Find( "/BrowserApplication//BrowserWindow//
            SparkApplication" )
        ButtonBar = Application.SparkButtonBar()

        Workbench.Verify(ButtonBar.GetStyle( "fontSize" ), "12" )
    End Sub
End Module