Flex 3 includes a Java-based compiler API that lets you compile SWF and SWC files from Java applications. The API supports all the same options as the mxmlc and compc command-line tools. The API includes classes like Application, Logger, and Project.
The API’s JavaDocs are here: flex_compiler_api.zip (245K)
There is a PDF which describes usage here: Compiler API Guide (194K)