I've implemented the same thing in Flex for showing the scrollbar track highlighting when words in a TextArea are highlighted, and when items are selected in a List (it should work for a DataGrid too, but I haven't tested it).
The nice thing about my implementation is that it is very simple to set up. All you have to do is set the verticalScrollBarStyleName property on your List, DataGrid or TextArea, and then create your CSS to set the trackSkin style to one of my two custom skins and it will all work.
E.g.
<mx:Style>
.highlightList {
track-skin: ClassReference("skins.HighlightListScrollTrackSkin");
}
.highlightTextArea {
trackSkin: ClassReference("skins.HighlightTextAreaScrollTrackSkin");
}
</mx:Style>
<mx:List verticalScrollBarStyleName="highlightList"/>
.highlightList {
track-skin: ClassReference("skins.HighlightListScrollTrackSkin");
}
.highlightTextArea {
trackSkin: ClassReference("skins.HighlightTextAreaScrollTrackSkin");
}
</mx:Style>
<mx:List verticalScrollBarStyleName="highlightList"/>
The text highlighting in the TextArea is done using some useful code that I found on this blog:
How to Highlight the Text in Flex.
I slightly modified the com.components.BlockTextArea class to make it work with my skins.HighlightTextAreaScrollTrackSkin class.
Here's the example (right click to View Source):
You can also set two more styles if you want to customize the color and alpha transparency of the highlighting:
highlight-color and highlight-alpha. Just add it to the css classes shown above.