Posts Tagged ‘Using Arrays for style’

Using Arrays for style properties of Tree component in Flex 4 or Flash Builder

February 1st, 2011 by aabhaanjan

By assigning colors to a property in an Array using comma-separated list to the property’s definition we can use array for style properties. The index is assigned to each entry in the order that it appears in the list.

Tree control’s depthColors style property can use a different background color for each level in the tree.

Example :

[xml]

<?xml version=”1.0″?>

<s:Application

xmlns:fx=”http://ns.adobe.com/mxml/2009″

xmlns:mx=”library://ns.adobe.com/flex/mx”

xmlns:s=”library://ns.adobe.com/flex/spark”>

<fx:Style>

@namespace mx “library://ns.adobe.com/flex/mx”;

mx|Tree {

depthColors: #FF3300, #FFCC99, #CC9900;

}

</fx:Style>

<fx:Declarations>

<fx:XMLList id=”treeData”>

<node label=”Node 1″>

<node label=”subnode1″>

<node label=”text1″/>

<node label=”text2″/>

<node label=”text3″/>

</node>

<node label=”subnode2″>

<node label=”text1″/>

<node label=”text2″/>

</node>

<node label=”text1″/>

<node label=”text2″/>

</node>

</fx:XMLList>

</fx:Declarations>

<s:Panel title=”Style Using Array” width=”100%”>

<mx:Tree id=”myTree” width=”100%” labelField=”@label” dataProvider=”{treeData}”/>

[/xml]

Tags: ,