Screen grab within Flash and output to JPEG?

Hi Folks,

Can anybody give me an idea how I might create a jpeg of a portion of the currently running Flash swf from within the swf? I am assuming that I would either need some way of flattening the multiple layers which make up the area to be exported or some type of screen grab would be required. Any suggestions/help would be greatly appreciated.

Thanks.

Glen