<p>I am just getting started with flex and am using the SDK (not Flex Builder). I was wondering what's the best way to compile a mxml file from an ant build script. </p>

[{'answer_id': 78248, 'author': 'mikechambers', 'author_id': 10232, 'author_profile': 'https://Stackoverflow.com/users/10232', 'pm_score': 4, 'selected': True, 'text': '<p>The Flex SDK ships with a set of ant tasks. More info at:</p>\n\n<p><a href="http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html" rel="noreferrer">http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html</a></p>\n\n<p>Here is an example of compiling Flex SWCs with ant:</p>\n\n<p><a href="http://www.mikechambers.com/blog/2006/05/19/example-using-ant-with-compc-to-compile-swcs/" rel="noreferrer">http://www.mikechambers.com/blog/2006/05/19/example-using-ant-with-compc-to-compile-swcs/</a></p>\n\n<p>mike chambers</p>\n'}, {'answer_id': 80511, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>If you\'re open to Maven, try the flex-compiler-mojo plugin:</p>\n\n<p><a href="http://code.google.com/p/flex-mojos/" rel="nofollow noreferrer">http://code.google.com/p/flex-mojos/</a></p>\n\n<p>Christiaan</p>\n'}, {'answer_id': 222331, 'author': 'jgormley', 'author_id': 29738, 'author_profile': 'https://Stackoverflow.com/users/29738', 'pm_score': 3, 'selected': False, 'text': '<p>I would definitely go with the ant tasks that are included with Flex, they make your build script so much cleaner.  Here is a sample build script that will compile and then run your flex project</p>\n\n<pre><code>&lt;?xml version="1.0"?&gt;\n\n&lt;project name="flexapptest" default="buildAndRun" basedir="."&gt;\n\n    &lt;!-- \n        make sure this jar file is in the ant lib directory \n        classpath="${ANT_HOME}/lib/flexTasks.jar" \n    --&gt;\n    &lt;taskdef resource="flexTasks.tasks" /&gt;\n    &lt;property name="appname" value="flexapptest"/&gt;\n    &lt;property name="appname_main" value="Flexapptest"/&gt;\n    &lt;property name="FLEX_HOME" value="/Applications/flex_sdk_3"/&gt;\n    &lt;property name="APP_ROOT" value="."/&gt;\n    &lt;property name="swfOut" value="dist/${appname}.swf" /&gt;\n    &lt;!-- point this to your local copy of the flash player --&gt;\n    &lt;property name="flash.player" location="/Applications/Adobe Flash CS3/Players/Flash Player.app" /&gt;\n\n    &lt;target name="compile"&gt;\n        &lt;mxmlc file="${APP_ROOT}/src/${appname_main}.mxml"\n            output="${APP_ROOT}/${swfOut}" \n            keep-generated-actionscript="true"&gt;\n\n            &lt;default-size width="800" height="600" /&gt;\n            &lt;load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/&gt;\n            &lt;source-path path-element="${FLEX_HOME}/frameworks"/&gt;\n            &lt;compiler.library-path dir="${APP_ROOT}/libs" append="true"&gt;\n                &lt;include name="*.swc" /&gt;\n            &lt;/compiler.library-path&gt;\n        &lt;/mxmlc&gt;\n    &lt;/target&gt;\n\n    &lt;target name="buildAndRun" depends="compile"&gt;\n        &lt;exec executable="open"&gt;\n            &lt;arg line="-a \'${flash.player}\'"/&gt;\n            &lt;arg line="${APP_ROOT}/${swfOut}" /&gt;\n        &lt;/exec&gt;\n    &lt;/target&gt;\n\n    &lt;target name="clean"&gt;\n        &lt;delete dir="${APP_ROOT}/src/generated"/&gt;\n        &lt;delete file="${APP_ROOT}/${swfOut}"/&gt;\n    &lt;/target&gt;\n\n&lt;/project&gt;\n</code></pre>\n'}, {'answer_id': 1670928, 'author': 'Luke Bayes', 'author_id': 105023, 'author_profile': 'https://Stackoverflow.com/users/105023', 'pm_score': 2, 'selected': False, 'text': '<p>There is another option - it\'s called <a href="http://projectsprouts.org" rel="nofollow noreferrer">Project Sprouts</a>.</p>\n\n<p>This is a system built with Ruby, RubyGems and Rake that provides many of the features found in Maven and ANT, but with a much cleaner syntax and simpler build scripts.</p>\n\n<p>For example, the ANT script shown above would look like this in Sprouts:</p>\n\n<pre><code>require \'rubygems\'\nrequire \'sprout\'\n\ndesc \'Compile and run the SWF\'\nflashplayer :run =&gt; \'bin/SomeProject.swf\'\n\nmxmlc \'bin/SomeProject.swf\' do |t|\n  t.input = \'src/SomeProject.as\'\n  t.default_size = \'800 600\'\n  t.default_background_color = \'#ffffff\'\n  t.keep_generated_actionscript = true\n  t.library_path &lt;&lt; \'libs\'\nend\n\ntask :default =&gt; :run\n</code></pre>\n\n<p>After installing Ruby and RubyGems, you would simply call this script with:</p>\n\n<pre><code>rake\n</code></pre>\n\n<p>To remove generated files, run:</p>\n\n<pre><code>rake clean\n</code></pre>\n\n<p>To see available tasks:</p>\n\n<pre><code>rake -T\n</code></pre>\n\n<p>Another great benefit of Sprouts, once installed, is that it provides project, class and test generators that will get any development box ready to run with a couple simple command line actions.</p>\n\n<pre><code># Generate a project and cd into it:\nsprout -n mxml SomeProject\ncd SomeProject\n\n# Compile and run the main debug SWF:\nrake\n\n# Generate a new class, test case and test suite:\nscript/generate class utils.MathUtil\n\n# Compile and run the test harness:\nrake test\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/78230', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1227001/']