Thanks Doug. As I said, I really don't know much about Flex programming. I don't quite understand how to implement your idea. Does this command go into my geoprocessing widget or is it in the LayerList widget? In my case, I open my gp widget, click a submit button, and then the output window in the widget will display the returned rest url. At the same time, the dynamic map service layer has been added on top of the base map in the flex viewer. I close my gp widget and open the layerlist widget, but no layers are there. In my case, I don't have any operational layers pre-defined in the flex viewer so mapswitcher isn't showing up either.
Thanks for you help.