If you are using ant then there actually is an open source solution that can help you to get started: https://code.google.com/p/fuelanttasks/ It allows you to create an ant macro like this:
<taskdef resource="FuelAntTasks.properties" classpath="FuelAntTasks.jar" />
<!--
This target shows how to use the fla task to publish an fla
-->
<target name="fla_publish">
<flash>
<fla file="${src}/redsquare.fla" build="publish"/>
<fla file="${src}/greensquare.fla" build="publish"/>
</flash>
</target>
It will take care of launching the flash ide, retrieving the logs and displaying them through ant.