How to compile a Flex project with RSL using Ant

[url]http://businessintelligence.me/blog_en/ria/rsl-compile-flex-project-ant/[/url]
Recently, we had to write an Ant script to build our application and put it under continuous integration. At the beginning, we passed the minimum arguments to the compiler to build the SWF file and it compiled the project, including the framework classes, in the application SWF file.
So, how to use RSL winthin an ant script to reduce the size of the swf result file ?
Firs of all, you have to use a configuration file witch specifies a lots of information to the compiler about your application like the name, the player version, etc. So, you can create your own configuration file and specify all the informations needed. A sample of the file is in the flex sdk named “flex-config.xml”. Inside this file, you can write a tag runtime-shared-library-path witch specify the SWC file you want to use as an RSL.
An example of the config file may be:
<flex-config>
<compiler>

</compiler>
<runtime-shared-library-path>
<path-element>libs/framework.swc</path-element>
<rsl-url>framework_3.2.0.3958.swz</rsl-url>
<policy-file-url></policy-file-url>
<rsl-url>framework_3.2.0.3958.swf</rsl-url>
<policy-file-url></policy-file-url>
</runtime-shared-library-path>

</flex-config>

The <path-element> tag is the relative path to the library file, the <rsl-url> is the relative url of the RSL relatively to the root server path and the <policy-file-url> is the relative URL for the crossdomain.xml file. If not specify, flash will try to find it at the root of the server.
Now we can use this file in our ant task as a config file for the compiler. Therefore, the compiler will create correct links to the RSL in the project SWF file.
This is a sample how to use the config file:
<mxmlc file="..." >

<load-config filename=”${basedir}/flex-config.xml”/>

</mxmlc>

After the build, the SWF file of the project is smaller than before and you have just to put the framework.swz and framework.swf file at the correct location on the server to use them as Runtime Shared Libraries !
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值