欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

How to compile a Flex project with RSL using Ant

程序员文章站 2022-07-03 23:33:28
...
[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 !