The following example shows how you can remove the track skin from a Flex List control by setting the trackSkin style to null.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/04/10/removing-the-track-skin-from-a-list-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Style>
.tracklessScrollBar {
trackSkin: ClassReference(null);
}
</mx:Style>
<mx:Script>
<![CDATA[
import mx.events.ItemClickEvent;
private function toggleButtonBar_itemClick(evt:ItemClickEvent):void {
list.setStyle("verticalScrollBarStyleName", evt.item.data);
}
]]>
</mx:Script>
<mx:Array id="arr">
<mx:Object label="One" />
<mx:Object label="Two" />
<mx:Object label="Three" />
<mx:Object label="Four" />
<mx:Object label="Five" />
<mx:Object label="Six" />
<mx:Object label="Seven" />
<mx:Object label="Eight" />
<mx:Object label="Nine" />
<mx:Object label="Ten" />
</mx:Array>
<mx:Array id="dp">
<mx:Object label="default (undefined)"
data="{undefined}" />
<mx:Object label="tracklessScrollBar"
data="tracklessScrollBar" />
</mx:Array>
<mx:ApplicationControlBar dock="true">
<mx:ToggleButtonBar id="toggleButtonBar"
dataProvider="{dp}"
itemClick="toggleButtonBar_itemClick(event);" />
</mx:ApplicationControlBar>
<mx:List id="list"
dataProvider="{arr}"
rowCount="6"
width="100" />
</mx:Application>
View source is enabled in the following example.
You can also set the verticalScrollBarStyleName style in an external .CSS file or <mx:Style /> block, as seen in the following snippet:
<mx:Style>
List {
verticalScrollBarStyleName: tracklessScrollBar;
}
.tracklessScrollBar {
trackSkin: ClassReference(null);
}
</mx:Style>
Or, you can set the verticalScrollBarStyleName style directly within MXML, as seen in the following snippet:
<mx:List id="list"
dataProvider="{arr}"
rowCount="6"
width="100"
verticalScrollBarStyleName="tracklessScrollBar" />
For more examples of customizing the vertical scroll bar in Flex components, see http://blog.flexexamples.com/tag/verticalscrollbarstylename/.




0 Responses to “Removing the track skin from a List control in Flex”
Leave a Reply