您的位置:首页 > 其它

关于Flex Ant的相关注意事项

2011-11-01 10:10 225 查看
1、代码方面:

如果是Embed的方法,务必按以下方式写,注意反斜杠的位置。

在mxml文件中:

<mx:Image  source="@Embed('/cn/com/1.png')"/>


在CSS文件中:

backgroundImage:Embed(source="/cn/com/1.png");


.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

在AS文件中:

[Embed(source="/cn/com/1.png")]
public var zmouse : Class;


.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

2、图片以及附件的处理方面:

如果是Embed进去的,这些就不需要处理了,那未打包的资源就是一个比较麻烦的地方,偶也没有找到比较好的方法,似乎只能一个个写,参考其提供的样例:

<compc fork="true"
output="${basedir}/${THEME_NAME}.swc">
<!-- If you change this, update ${local.playerglobal.version} above. -->
<target-player>10</target-player>
<jvmarg line="${compc.jvm.args}"/>
<include-classes>ArcadeClasses</include-classes>
<source-path path-element="${basedir}/src"/>
<library-path />
<external-library-path dir="${FLEX_HOME}/frameworks/libs">
<include name="player/${local.playerglobal.version}/playerglobal.swc"/>
<include name="framework.swc"/>
<include name="spark.swc"/>
<include name="textLayout.swc"/>
<include name="osmf.swc"/>
</external-library-path>
<include-file name="defaults.css" path="${basedir}/src/defaults.css"/>
<include-file name="assets/flex_skins.swf" path="${basedir}/src/assets/flex_skins.swf"/>
<include-file name="preview.jpg" path="${basedir}/src/preview.jpg"/>
<include-file name="metadata.xml" path="${basedir}/src/metadata.xml"/>
<locale/>
<accessible>true</accessible>
</compc>


.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

3、样式的处理:

如果采用的动态加载样式 ,那么尽量将相关的库打包至样式的SWF中,否则可能会出现部分样式加载延迟的问题,关于static-link-runtime-shared-libraries的使用可以Google一下!

<target name="buildcss" depends="init">
<mxmlc file="${SRC_DIR}/cn/com/egova/umgis/common/style/CustomStyle.css"
output="${DEPLOY_DIR}/cn/com/egova/umgis/common/style/CustomStyle.swf">
<static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
</mxmlc>
</target>


.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

4、关于文件大小

采用Ant打包的文件相比使用Flash Builder自动编绎生成的文件大概要小一半左右,这是因为其自动编译的文件为了避免出错,会将一些共享库打包至SWF中,因此会造成SWF庞大,但至于使用Ant打包后的是不是会有其他问题,暂时还没有验证。

参考资源:

http://www.petersheim.org/wiki/index.php/Flex_Ant_Task

http://blog.ityao.com/archives/751

http://mxcode.com/2010/11/flex-ant-file-sample/

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: