Creating swf on server

How should I go about doing this? I want to dynamically create swf on the fly and store it on the server… how can I do it?