现在的位置: 首页 > 综合 > 正文

使用RSL发布flex项目需要的build.xml要诀详解 – IT妖怪

2014年01月11日 ⁄ 综合 ⁄ 共 8112字 ⁄ 字号 评论关闭


Silver
撰写
 

遇到了一个ANT编译后不能正常发布使用的问题,于是花了两天(人比较呆)去研究,研究得这么辛苦,当然要把心得写下来,对于ADOBE貌似详细,但语蔫不详的文档作风很是失望!
在此感谢此文作者:http://www.kahunaburger.com/2009/04/08/flash-player-verifyerror-error-1014-with-rsls/
给了我解决问题的思路

要是用flash build 4.1自带的flex 4.1的sdk的flex-config.xml记得更新里面的默认编译FP版本为10.1,否则还是10.0的

build.properties文件

1
2
3
4
5
6
7
8
#Flex SDK 路径
FLEX_HOME=G:\\flexsdk
#根目录
APP_ROOT=G:\\riasource\\0.trunk
#ANT 安装目录
ANT_HOME=D:\\tools\\apache-ant-1.8.0
#本地部署目录(wamp/www)
DEPLOY_DIR=E:/wamp/www/ihaveu2

build.xml文件

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?xml
version="1.0"
encoding="utf-8"?>
<project
name="Task Build Main Script"
default="build"
basedir=".">
    <!-- 加载全局properties -->
    <property
file="../build.properties"
/>
    <!-- 源文件路径 -->
    <property
name="SRC_DIR"
value="${basedir}/srcs"
/>
    <!-- assets路径 -->
    <property
name="ASSETS_DIR"
value="${basedir}/assets"
/>
    <!-- config路径-->
    <property
name="CONFIG_DIR"
value="${APP_ROOT}/main/config/locale"
/>
    <!-- 引入flexTasks.jar -->
    <taskdef
resource="flexTasks.tasks"
classpath="${FLEX_HOME}/ant/lib/flexTasks.jar"
/>
    <taskdef
resource="net/sf/antcontrib/antlib.xml">
        <classpath>
            <pathelement
location="${ANT_HOME}/lib/ant-contrib-1.0b3"
/>
        </classpath>
    </taskdef>
 
    <!-- 优化和生成项目需要用到的RSL -->
    <target
name="createRSL">
        <macrodef
name="optimize-rsl">
            <attribute
name="rsl-dir"
/>
            <attribute
name="swc-dir"
/>
            <attribute
name="swc-name"
/>
            <sequential>
                <unzip
src="@{swc-dir}/@{swc-name}.swc"
dest="@{rsl-dir}">
                    <patternset>
                        <include
name="library.swf"
/>
                    </patternset>
                </unzip>
                <java
jar="${FLEX_HOME}/lib/optimizer.jar"
fork="true"
failonerror="true">
                    <jvmarg
line="-ea -DAS3 -DAVMPLUS -Dflexlib=${FLEX_HOME}/frameworks -Xms32m -Xmx384m -Dsun.io.useCanonCaches=false"
/>
                    <arg
line="'@{rsl-dir}/library.swf' --output '@{rsl-dir}/@{swc-name}.swf' --keep-as3-metadata='Bindable,Managed,ChangeEvent,NonCommittingChangeEvent,Transient,RemoteClass' "
/>
                </java>
                <delete
file="@{rsl-dir}/library.swf"
/>
                <java
jar="${FLEX_HOME}/lib/digest.jar"
fork="true"
failonerror="true">
                    <jvmarg
line="-ea -DAS3 -DAVMPLUS -Xms32m -Xmx384m -Dsun.io.useCanonCaches=false"
/>
                    <arg
line="--digest.rsl-file  @{rsl-dir}/@{swc-name}.swf --digest.swc-path  @{swc-dir}/@{swc-name}.swc"
/>
                </java>
            </sequential>
        </macrodef>      
 
        <!--把项目依赖的swc变成我们需要的RSL文件-->
        <optimize-rsl
rsl-dir="${DEPLOY_DIR}"
swc-dir="${APP_ROOT}/library/bins"
swc-name="ihaveuLib_magazine"
/>
        <optimize-rsl
rsl-dir="${DEPLOY_DIR}"
swc-dir="${APP_ROOT}/library/bins"
swc-name="ihaveuLib_main"
/>
        <optimize-rsl
rsl-dir="${DEPLOY_DIR}"
swc-dir="${APP_ROOT}/referenceLibs/bins"
swc-name="PureMVC_AS3_MultiCore_1_0_5"
/>
        <optimize-rsl
rsl-dir="${DEPLOY_DIR}"
swc-dir="${APP_ROOT}/referenceLibs/bins"
swc-name="TweenLite"
/>
    </target>
 
    <!-- 构建web项目  -->
    <target
name="build"
depends="createRSL"
>
        <exec
executable="svnversion"
outputproperty="revisionVersion"
/>
        <copy
todir="${DEPLOY_DIR}">
            <fileset
dir="${SRC_DIR}/web_runtime">
                <include
name="**/**"
/>
            </fileset>
        </copy>
 
        <copy
todir="${DEPLOY_DIR}/assets">
            <fileset
dir="${ASSETS_DIR}/web_runtime">
                <include
name="**/**"
/>
            </fileset>
            <!--
            <fileset dir="${ASSETS_DIR}/air_runtime">
                <include name="**/**" />
            </fileset>
            -->
        </copy>
 
        <mxmlc
file="${DEPLOY_DIR}/index.mxml">
            <!-- 方便可以进行远程debug -->
            <debug>true</debug>
            <!-- 项目需要用到的locale名字,其中在SDK 4.1 里面framework locale目录zh_tw已经改成zh_TW,但千万别信,使用的时候还是要写成zh_tw -->
            <locale>en_US</locale>
            <locale>zh_CN</locale>
            <locale>zh_tw</locale>
            <!--项目的多语言及配置文件目录-->
            <source-path
path-element="${CONFIG_DIR}/en_US"
/>
            <source-path
path-element="${CONFIG_DIR}/zh_CN"
/>
            <source-path
path-element="${CONFIG_DIR}/zh_tw"
/>
            <!-- 依赖的flex 4.1框架的RSL, 注意:顺序不能乱!若不写这一段则会报错:VerifyError: Error #1014: 无法找到类 。估计是由于下面自己定义的RSL依赖次序被优先了 -->
            <runtime-shared-library-path
path-element="${FLEX_HOME}/frameworks/libs/framework.swc">
                <url
rsl-url="framework_4.1.0.16076.swz"/>
            </runtime-shared-library-path>
            <runtime-shared-library-path
path-element="${FLEX_HOME}/frameworks/libs/textLayout.swc">
                <url
rsl-url="textLayout_1.1.0.604.swz"/>
            </runtime-shared-library-path>
            <runtime-shared-library-path
path-element="libs/osmf.swc">
                <url
rsl-url="osmf_flex.4.0.0.13495.swz"/>
            </runtime-shared-library-path>
            <runtime-shared-library-path
path-element="${FLEX_HOME}/frameworks/libs/spark.swc">
                <url
rsl-url="spark_4.1.0.16076.swz"/>
            </runtime-shared-library-path>
            <runtime-shared-library-path
path-element="${FLEX_HOME}/frameworks/libs/sparkskins.swc">
                <url
rsl-url="sparkskins_4.1.0.16076.swz"/>
            </runtime-shared-library-path>
            <runtime-shared-library-path
path-element="${FLEX_HOME}/frameworks/libs/rpc.swc">
                <url
rsl-url="rpc_4.1.0.16076.swz"
/>
            </runtime-shared-library-path>
            <!-- 依赖的第三方RSL, 如果有依赖关系,则应该按照依赖次序 进行定义-->
            <runtime-shared-library-path
path-element="${APP_ROOT}/referenceLibs/bins/PureMVC_AS3_MultiCore_1_0_5.swc">
                <url
rsl-url="PureMVC_AS3_MultiCore_1_0_5.swf"
policy-file-url=""/>
            </runtime-shared-library-path>
            <runtime-shared-library-path
path-element="${APP_ROOT}/referenceLibs/bins/TweenLite.swc">
                <url
rsl-url="TweenLite.swf"
policy-file-url=""/>
            </runtime-shared-library-path>       
 
            <runtime-shared-library-path
path-element="${APP_ROOT}/library/bins/ihaveuLib_main.swc">
                <url
rsl-url="ihaveuLib_main.swf"
policy-file-url=""/>
            </runtime-shared-library-path>
            <runtime-shared-library-path
path-element="${APP_ROOT}/library/bins/ihaveuLib_magazine.swc">
                <url
rsl-url="ihaveuLib_magazine.swf"
policy-file-url=""/>
            </runtime-shared-library-path>
            <!-- 指定哪些包是不需要编译进输出的swf, 不写这段会把框架打包进index.swf里面去 -->
            <external-library-path
dir="${FLEX_HOME}/frameworks/libs"
append="true">
                <include
name="*.swc"
/>
                <include
name="air/*.swc"
/>
            </external-library-path>
        </mxmlc>
    </target>
</project>

转载地址:http://blog.ityao.com/archives/751

抱歉!评论已关闭.