using ant to build flash

2025-12-11 0 260

Using ANT to build flash

A collection of examples of using ANT to automate building flash apps/games. It\’s meant to be a cook book or a learning resource, therefore
each example is as small as possible and should be self-describing.

Make your build continuous integration ready!

Introduction

Environment

Java

At first of all, you have to install JRE (Java Runtime Environment). To check everything works as expected, just type $ java to your terminal.

ANT

Then you have to download ANT from http://ant.ap***ache.org/bindownload.cgi. Just extract the downloaded .zip file into the, let\’s say ~/sdks/ant directory, set ANT_HOME environment variable to this location and add ANT_HOME to PATH:

${ANT_HOME}/bin (MacOS) or %ANT_HOME%/bin (Windows)

To check everything works as expected, just type $ ant to your terminal.

If you are using MacOS you can install ANT with brew: $ brew install ant

AIR SDK

If you are using Adobe Flash Builder 4.7, you can find the AIR SDK at /Applications/Adobe Flash Builder 4.7/eclipse/plugins/com.adobe.flash.compiler_4.7.0.349722 (MacOS) or C:\\Program Files (x86)\\Adobe\\Adobe Flash Builder 4.7\\eclipse\\plugins\\com.adobe.flash.compiler_4.7.0.349722 (Windows).

Otherwise, you can download it from http://www.*ad**obe.com/devnet/air/air-sdk-download.html. Just extract it into the, let\’s say ~/sdks/air directory.

FLEX SDK

If you are using Adobe Flash Builder 4.7, you can find the Flex SDKs directory at <FlashBuilder_installation_location>/sdks.

Otherwise, you have to download and install it manually. I personally prefer release by Adobe, which can be downloaded from http://www.a*d*o*be.com/devnet/flex/flex-sdk-download.html. Just extract it into the, let\’s say ~/sdks/flex directory. But you may want to use the latest version of the Flex SDK, which is currently developed by Apache. If so, you can install it using their http://flex.a***pache.org/installer.html.

You should set the FLEX_HOME environment variable and add it to PATH.

Compilers and tools

mxmlc

You use the application compiler to compile SWF files from your ActionScript and/or MXML source files.

  • Using mxmlc, the application compiler
  • compiler options

compc

You use the component compiler to generate a SWC file from component source files and other asset files such as images and style sheets.

  • Using compc, the component compiler
  • About the component compiler options

amxmlc

You can compile the ActionScript and MXML assets of your AIR application with the command line MXML compiler (amxmlc).

  • Compiling an AIR application with the amxmlc compiler

acompc

Use the component compiler, acompc, to compile AIR libraries and independent components.

  • Compiling an AIR component or library with the acompc compiler

ASDoc

ASDoc is a command-line tool that you can use to create API language reference documentation as HTML pages from the ActionScript classes and MXML files.

ADT

The AIR Developer Tool is a multi-purpose, command-line tool for developing AIR applications. You can use ADT to perform the following tasks:

  • Package an AIR application as an .air installation file
  • Package an AIR application as a native installer—for example, as a .exe installer file on Windows, .ipa on iOS, or .apk on Android
  • Package a native extension as an AIR Native Extension (ANE) file
  • Sign an AIR application with a digital certificate
  • Change (migrate) the digital signature used for application updates
  • Determine the devices connected to a computer
  • Create a self-signed digital code signing certificate
  • Remotely install, launch, and uninstall an application on a mobile device
  • Remotely install and uninstall the AIR runtime on a mobile device

ADL

Use the AIR Debug Launcher to run both SWF-based and HTML-based applications during development. Using ADL, you can run an application without first packaging and installing it. By default, ADL uses a runtime included with the SDK, which means you do not have to install the runtime separately to use ADL.

Building SWC

Example 1 – basics

The most simple ANT build.xml file, which describes how to build an bin/output.swc file:

<?xml version=\"1.0\"?>
<project name=\"swc example\" default=\"main\" basedir=\".\">
	<taskdef resource=\"flexTasks.tasks\" classpath=\"${FLEX_HOME}/ant\"/>
	<property name=\"DEPLOY.dir\" value=\"${basedir}/bin\"/>
	<target name=\"main\" depends=\"clean, compile\"/>
	<target name=\"clean\">
		<delete dir=\"${DEPLOY.dir}\"/>
		<mkdir dir=\"${DEPLOY.dir}\"/>
	</target>
	<target name=\"compile\">
	<compc output=\"${DEPLOY.dir}/output.swc\" failonerror=\"true\" maxmemory=\"1024m\">
		<source-path path-element=\"${basedir}/src\"/>
		<include-sources dir=\"${basedir}/src\" includes=\"*\"/>
	</compc>
</target>
</project>

Example 2 – linking libs directory

Let\’s say, that the project contains a libs directory with linked .swc libraries. We have to tell to compc where to find them:

<?xml version=\"1.0\"?>
<project name=\"swc example\" default=\"main\" basedir=\".\">
	<taskdef resource=\"flexTasks.tasks\" classpath=\"${FLEX_HOME}/ant\"/>
	<property name=\"DEPLOY.dir\" value=\"${basedir}/bin\"/>
	<target name=\"main\" depends=\"clean, compile\"/>
	<target name=\"clean\">
		<delete dir=\"${DEPLOY.dir}\"/>
		<mkdir dir=\"${DEPLOY.dir}\"/>
	</target>
	<target name=\"compile\">
	<compc output=\"${DEPLOY.dir}/output.swc\" failonerror=\"true\" maxmemory=\"1024m\">
		<source-path path-element=\"${basedir}/src\"/>
		<include-sources dir=\"${basedir}/src\" includes=\"*\"/>
		<library-path dir=\"${basedir}/libs\" includes=\"*\" append=\"true\"/>
	</compc>
</target>
</project>

Example 3 – linking another swc file

Or if we want to specify an .swc file located anywhere:

<?xml version=\"1.0\"?>
<project name=\"swc example\" default=\"main\" basedir=\".\">
	<taskdef resource=\"flexTasks.tasks\" classpath=\"${FLEX_HOME}/ant\"/>
	<property name=\"DEPLOY.dir\" value=\"${basedir}/bin\"/>
	<target name=\"main\" depends=\"clean, compile\"/>
	<target name=\"clean\">
		<delete dir=\"${DEPLOY.dir}\"/>
		<mkdir dir=\"${DEPLOY.dir}\"/>
	</target>
	<target name=\"compile\">
	<compc output=\"${DEPLOY.dir}/output.swc\" failonerror=\"true\" maxmemory=\"1024m\">
		<source-path path-element=\"${basedir}/src\"/>
		<include-sources dir=\"${basedir}/src\" includes=\"*\"/>
		<library-path file=\"lib.swc\" append=\"true\"/>
	</compc>
</target>
</project>

Example 4 – custom metadata

Now we are using custom metadata and we want to keep them in compiled application (the default behavior is that they are removed them to keep the application/library as small as possible):

<?xml version=\"1.0\"?>
<project name=\"swc example\" default=\"main\" basedir=\".\">
	<taskdef resource=\"flexTasks.tasks\" classpath=\"${FLEX_HOME}/ant\"/>
	<property name=\"DEPLOY.dir\" value=\"${basedir}/bin\"/>
	<target name=\"main\" depends=\"clean, compile\"/>
	<target name=\"clean\">
		<delete dir=\"${DEPLOY.dir}\"/>
		<mkdir dir=\"${DEPLOY.dir}\"/>
	</target>
	<target name=\"compile\">
	<compc output=\"${DEPLOY.dir}/output.swc\" failonerror=\"true\" maxmemory=\"1024m\">
		<source-path path-element=\"${basedir}/src\"/>
		<include-sources dir=\"${basedir}/src\" includes=\"*\"/>
		<library-path dir=\"${basedir}/libs\" includes=\"*\" append=\"true\"/>
		<keep-as3-metadata name=\"Inject\"/>
		<keep-as3-metadata name=\"PostConstruct\"/>
		<keep-as3-metadata name=\"ArrayElementType\"/>
	</compc>
</target>
</project>

Example 5 – changing target player version

<compc ... target-player=\"11.4\" swf-version=\"17\"/>

Do not forget to check if FLEX_HOME/frameworks/libs/player/<target-version>/playerglobal.swc and ${FLEX_HOME}/runtimes/player/<target-version>/.../FlashPlayerDebugger exist. You can find all released versions of playerglobal.swc and Flash Player Debuggers at http://helpx.a*do**be.com/flash-player/kb/archived-flash-player-versions.html.

swf-version target-player
9 9
10 10.0, 10.1
11 10.2
12 10.3
13 11.0
14 11.1
15 11.2
16 11.3
17 11.4
18 11.5
19 11.6
20 11.7
21 11.8
22 11.9
23 12.0
24 13.0
25 14.0
26 15.0
27 16.0

Example 6 – dump details about compilation

Let\’s take a look at the compc options. If you are intrested in more detailed informations, you can dump out config, size report and link report:

<compc ... dump-config=\"${DEPLOY.dir}/config.xml\" size-report=\"${DEPLOY.dir}/sizereport.xml\" link-report=\"${DEPLOY.dir}/linkreport.xml\">

Example 7 – disable warnings

To disable warnings:

<compc ... warnings=\"false\">

Example 8 – exhausted memory error

If you are building a lot of applications/libraries, you can exhaust the memory. Very useful is set fork option to true, which should solve, especially with maxmemory set to at least one gig, everything:

<compc ... fork=\"true\">

Building SWF from Flex project

Example 9 – basics

The most simple ANT build.xml file, which describes how to build a bin/output.swf file:

<?xml version=\"1.0\"?>
<project name=\"swf example\" default=\"main\" basedir=\".\">
	<taskdef resource=\"flexTasks.tasks\" classpath=\"${FLEX_HOME}/ant\"/>
	<property name=\"DEPLOY.dir\" value=\"${basedir}/bin\"/>
	<target name=\"main\" depends=\"clean, compile\"/>
	<target name=\"clean\">
		<delete dir=\"${DEPLOY.dir}\"/>
		<mkdir dir=\"${DEPLOY.dir}\"/>
	</target>
	<target name=\"compile\">
		<mxmlc file=\"${basedir}/src/Main.mxml\" output=\"${DEPLOY.dir}/output.swf\" failonerror=\"true\" maxmemory=\"1024m\">
			<source-path path-element=\"${basedir}/src\"/>
		</mxmlc>
	</target>
</project>

The mxmlc compiler offers almost the same options as the compc compiler does. Each example described in Building SWC section can be easily changed to mxmlc command. Compare Example 1 with Example 9 and you\’ll see.

Building SWF from pure ActionScript project

Example 10 – basics

The most simple ANT build.xml file, which describes how to build an bin/output.swf file:

<?xml version=\"1.0\"?>
<project name=\"swf example\" default=\"main\" basedir=\".\">
	<taskdef resource=\"flexTasks.tasks\" classpath=\"${FLEX_HOME}/ant\"/>
	<property name=\"DEPLOY.dir\" value=\"${basedir}/bin\"/>
	<target name=\"main\" depends=\"clean, compile\"/>
	<target name=\"clean\">
		<delete dir=\"${DEPLOY.dir}\"/>
		<mkdir dir=\"${DEPLOY.dir}\"/>
	</target>
	<target name=\"compile\">
		<mxmlc
			file=\"${basedir}/src/Main.as\"
			output=\"${DEPLOY.dir}/output.swf\"
			static-link-runtime-shared-libraries=\"true\"
			failonerror=\"true\"
			maxmemory=\"1024m\">
			<source-path path-element=\"${basedir}/src\"/>
			<source-path path-element=\"${FLEX_HOME}/frameworks\"/>
		</mxmlc>
	</target>
</project>

The mxmlc compiler offers almost the same options as the compc compiler does. Each example described in Building SWC section can be easily changed to mxmlc command. Compare Example 1 with Example 10 and you\’ll see.

Building AIR project

Example 11 – basics

The most simple ANT build.xml file, which describes how to build an bin/output.swf file:

<?xml version=\"1.0\"?>
<project name=\"swf example\" default=\"main\" basedir=\".\">
	<taskdef resource=\"flexTasks.tasks\" classpath=\"${FLEX_HOME}/ant\"/>
	<property name=\"DEPLOY.dir\" value=\"${basedir}/bin\"/>
	<target name=\"main\" depends=\"clean, compile\"/>
	<target name=\"clean\">
		<delete dir=\"${DEPLOY.dir}\"/>
		<mkdir dir=\"${DEPLOY.dir}\"/>
	</target>
	<target name=\"compile\">
		<mxmlc file=\"${basedir}/src/Main.as\" output=\"${DEPLOY.dir>/output.swf\" configname=\"air\" failonerror=\"true\">
			<library-path dir=\"${FLEX_HOME}\" append=\"true\">
				<include name=\"frameworks/libs\"/>
			</library-path>
			<library-path dir=\"${FLEX_HOME}\" append=\"true\">
				<include name=\"frameworks/libs/air\"/>
			</library-path>
		</mxmlc>
	</target>
</project>

The mxmlc compiler offers almost the same options as the compc compiler does. Each example described in Building SWC section can be easily changed to mxmlc command. Compare Example 1 with Example 11 and you\’ll see.

Running FlexUnit tests in FlashPlayer

Quick download links: Apache FlexUnit 4.2, FlexUnit 4.1

Example 12 – running FlexUnit tests in FlashPlayer

Do not forget to add CIListener to your FlexUnitCore instance.

<?xml version=\"1.0\"?>
<project name=\"swf example\" default=\"main\" basedir=\".\">
	<taskdef resource=\"flexTasks.tasks\" classpath=\"${FLEX_HOME}/ant\"/>
	<taskdef resource=\"flexUnitTasks.tasks\">
		<classpath>
			<fileset dir=\"<path_to_flex_unit_ant_tasks_dir>\">
				<include name=\"flexUnitTasks*.jar\"/>
			</fileset>
		</classpath>
	</taskdef>
	<property name=\"DEPLOY.dir\" value=\"${basedir}/bin\"/>
	<property name=\"TESTS.dir\" value=\"${basedir}/tests-output\"/>
	<target name=\"main\" depends=\"clean, tests, compile\"/>
	<target name=\"clean\">
		<delete dir=\"${DEPLOY.dir}\"/>
		<mkdir dir=\"${DEPLOY.dir}\"/>
		<delete dir=\"${TESTS.dir}\"/>
		<mkdir dir=\"${TESTS.dir}\"/>
	</target>
	<target name=\"tests\">
		<mxmlc file=\"${basedir}/src/tests.mxml\" output=\"${TESTS.dir}/tests.swf\" failonerror=\"true\" verbose-stacktraces=\"true\">
			<source-path path-element=\"${basedir}/src\"/>
			<library-path dir=\"${basedir}/libs\" includes=\"*\" append=\"true\"/>
		</mxmlc>
		<flexunit
			swf=\"${TESTS.dir}/tests.swf\"
			toDir=\"${TESTS.dir}\"
			haltonfailure=\"false\" failureproperty=\"flexunit.failure\"
			verbose=\"true\"
			localTrusted=\"true\"
			command=\"${FLEX_HOME}/runtimes/player/11.4/win/FlashPlayerDebugger.exe\"/>
		<junitreport todir=\"${TESTS.dir}\">
			<fileset dir=\"${TESTS.dir}\">
				<include name=\"TEST-*.xml\"/>
			</fileset>
			<report format=\"frames\" todir=\"${TESTS.dir}/html\"/>
		</junitreport>
	</target>
	<target name=\"compile\">
		<mxmlc file=\"${basedir}/src/Main.mxml\" output=\"${DEPLOY.dir}/output.swf\" failonerror=\"true\" maxmemory=\"1024m\">
			<source-path path-element=\"${basedir}/src\"/>
		</mxmlc>
	</target>
</project>

Running FlexUnit tests in ADL

Example 13 – running FlexUnit tests in ADL

Do not forget to add AIRCIListener to your FlexUnitCore instance.

<?xml version=\"1.0\"?>
<project name=\"swf example\" default=\"main\" basedir=\".\">
	<taskdef resource=\"flexTasks.tasks\" classpath=\"${FLEX_HOME}/ant\"/>
	<taskdef resource=\"flexUnitTasks.tasks\">
		<classpath>
			<fileset dir=\"<path_to_flex_unit_ant_tasks_dir>\">
				<include name=\"flexUnitTasks*.jar\"/>
			</fileset>
		</classpath>
	</taskdef>
	<property name=\"DEPLOY.dir\" value=\"${basedir}/bin\"/>
	<property name=\"TESTS.dir\" value=\"${basedir}/tests-output\"/>
	<target name=\"main\" depends=\"clean, tests, compile\"/>
	<target name=\"clean\">
		<delete dir=\"${DEPLOY.dir}\"/>
		<mkdir dir=\"${DEPLOY.dir}\"/>
		<delete dir=\"${TESTS.dir}\"/>
		<mkdir dir=\"${TESTS.dir}\"/>
	</target>
	<target name=\"test\">
		<mxmlc file=\"${basedir}/src/tests.as\" output=\"${TESTS.dir}/tests.swf\" configname=\"air\" failonerror=\"tru

下载源码

通过命令行克隆项目:

git clone https://github.com/honzabrecka/using-ant-to-build-flash.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 建站资源 using ant to build flash https://www.zuozi.net/34711.html

tbt flash
上一篇: tbt flash
Font Awesome
下一篇: Font Awesome
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务