Lixin,
The directions on how to add this widget to a Flex Viewer project are included in the download from the code gallery page.
Lixin,
You are on your own when you want to use the widget outside the Flex Viewer. That would require alot of decoupling from the Flex Viewer framework.
All,
The new Flex Viewer 2.5 version of the TOC Widget is now available.
Version 2.5 - 12 Dec, 2011
* Added new Flex Viewer 2.5 Layer menu capability to TOC.
* Enhanced the visual appearance of the out of the box Flex Viewer 2.5 Layer options menu and added more options.
* You can choose to use esri's new description capability or the current functionality that the TOC Widget has for Metadata.