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

遇到了一个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文件

#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文件

<?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="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/framework_4.1.0.16076.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
				<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="http://fpdownload.adobe.com/pub/swz/tlf/1.1.0.604/textLayout_1.1.0.604.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
				<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="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/osmf_flex.4.0.0.13495.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
				<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="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/spark_4.1.0.16076.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
				<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="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/sparkskins_4.1.0.16076.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
				<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="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/rpc_4.1.0.16076.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
				<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>

Flex 4.1以及Flash Builder 4.0.1更新

针对Flash Player 10.1的开发工具更新,快更新吧!

Adobe has publicly pushed the Flex 4.1/Flash Builder 4.0.1 update, which includes:

The new Layout Mirroring feature for repurposing Flex UIs for deployment in right-to-left locales
Native support for Flash Player 10.1 and AIR 2 in the Flex SDK
Native support in Flash Builder 4.0.1 for building apps targeting SDK 4.1, AIR 2 or FP 10.1
Many critical bugfixes and enhancement requests for both Flex SDK and Flash Builder

Adobe has also officially debuted the next release of the Flex SDK, code-named Hero. We share with the world our amazing story of a single unified Flex framework that can be used to build applications for the web, desktop and mobile devices. With today’s debut, we released many new documents and feature specifications, including:

Inaugural launch of the new Hero opensource Flex page
Posting of several new Hero desktop and Hero mobile feature specifications
Updated the labs.adobe.com Flex Mobile content to announce our intent to add mobile development capabilities directly into the core Flex framework, including
o Updating the Flex and Mobile Whitepaper
o Updating the Flex and Mobile FAQ

Please help us spread the word regarding these announcements. You can find more details in the following two blog postings:
Flex SDK 4 and Flash Builder 4 Updates Now Available http://blogs.adobe.com/flex/archives/2010/06/flex_sdk_4_and_flash_builder_4.html
Introducing….Hero!

http://blogs.adobe.com/flex/archives/2010/06/introducinghero.html

深圳游戏公司招聘AS3开发人员

深圳新飞扬数码技术有限公司
2006年成立至今,“新飞扬”凝聚了一支年轻、稳定且富有创新意识,并在互联网数字娱乐行业拥有顶尖先进技术、国际化运营理念、及丰富市场经验的专业团队。
公司网址:www.sunfairs.com.cn

因公司发展需要现招聘as3开发工程师

任职要求:
1. 大专及以上学历;具备高度的责任心及团队精神,愿意接受挑战性的工作,能够及时高效完成任务;
2. 精通Action Script 3.0或Flex,熟悉OOP开发模式,懂PureMVC者优先;
3. 对Flash RIA开发感兴趣,2年以上OO编码经验、2年以上AS3编码经验,基础扎实学习能力强者亦可。有相关项目经验者优先;
4. 熟悉XML语言,熟悉Socket等各种通信方式,熟悉Flash与外部通信技术;
5. 有规范的编程风格和良好文档习惯,具有较强理解沟通能力、自学能力,项目分析经验;
6. 具有创新精神、能快速的融入团队、能承受较大的工作压力。
7. 对开发大型多人在线实时互动虚拟游戏有强烈的兴趣。

职位描述:
1.负责Flash(Actionscript)游戏客户端应用逻辑的编写;
2.能够和后台工程师配合,实现Flash和服务程序的数据交换功能;
3.与测试人员配合,了解并解决产品中存在的问题。

待遇: 3K-8K(可面议)
联系方式:
电话:0755-82824704
QQ:228171441
邮箱:hr@sunfairs.com.cn;showping@yeah.net

外部调用字体文件实现字体嵌入

为了能在客户浏览器上准确显示设计者设计使用的字体,需要将字体文件嵌入到程序中,实现起来分为 字体文件编译进swf 和 外部调用字体文件两种。

编译进swf中会导致swf文件体积骤然增大,让swf文件调用外部的字体文件则更加适用(此时的字体文件为swf格式的文件)

步骤一    创建swf格式的字体文件。创建外部css文件,定义嵌入字体@font-face{ src:url(“…./xxx/xxx/MSYHBD.TTF”)   font-family:XXX   };

在管理器窗口右键点击该css文件选择“将css编译为SWF”,执行编译,bindebug中会生成与该css同名的swf文件,此乃包含MSYHBD字体的文件,供其他程序调用。

步骤二    注意先将之前“将css编译为SWF”设置的勾选去掉,在程序代码中使用方法 styleManager.loadStyleDeclarations(“…./xxx/xxx/XXX.swf”)来调用;   编译运行。

END

Adobe Flash Player 10.1 and Adobe AIR 2 正式发布

Rachel Luxemburg wrote:

Hi All!

Adobe Flash Player 10.1 and Adobe AIR 2 are now available for Windows, Mac and Linux operating systems. To download the runtimes, go to http://get.adobe.com/flashplayer/ for Flash Player and
http://get.adobe.com/air/ for AIR 2.

More info is posted on the AIR team blog, http://blogs.adobe.com/air/ and the Flash Player Team blog http://blogs.adobe.com/flashplayer/.

We’re really excited that we’re finally “over the finish line” with these releases, there’s a lot of new features & some real performance improvements.

Please help spread the word, and enjoy!

Rachel

Parsley AIR发布问题解决方法

之前在项目中使用Parsley做为框架,在把依赖的swc用RSL进行发布AIR的情况下,会Inject不了,
后来发现是AIR在IDE里面进行release发布的时候应该是没有把相关的metadata实现编译进去,于是就查了一下,发现不使用IDE的重新编译,使用命令行手工打包可以解决这个问题,
命令行如下:

adt -package -storetype pkcs12 -keystore certificat e.p12 -storepass 123456 TestAirMetadata.air bin-debug/TestAirMetadata-app.xml -C bin-debug .

[娱乐ZT] 菊花文转换

近来由于敏感词的原因, 大家开始用菊花文了. 看起来很有趣,但是实际上很使用的.
原理其实就是按照简单的规则转换了字符而已.

浏览完整全文 »

Flash在IE全屏时 使用Deeplinking修改网址会退出全屏的bug解决方案

BUG描述:

IE浏览器下,Flash全屏时 一旦使用deeplinking修改网址参数,就会导致Flash退出全屏

解决方案:

在全屏时不再修改deeplinking, 而当退出全屏时,使用最后的deeplinking

可以侦听stage类的事件FullScreenEvent. FULL_SCREEN

在任何被添加到了舞台的DisplayObject对象内部,都可以这样写:

this.stage.addEventListener(FullScreenEvent.FULL_SCREEN, stage_fullScreenHandler);

//侦听全屏变化的事件

private function stage_fullScreenHandler(event:FullScreenEvent):void{

//event.fullScreen为false的时候,是退出全屏,true是进入全屏

if(!event.fullScreen){

//修改deeplinking

}

Flex4 SkinnableContainer,BorderContainer隐藏子内容

SkinnableContainer及其子类BorderContainer等在添加了子内容后,

即使子内容宽高超过了容器本身的宽高,子内容也会被正常显示出来,

SkinnableContainer是无法裁剪子内容的,而且也没有默认属性可以设置

但如果想实现容器裁剪子内容,可以用以下方法实现

<s: SkinnableContainer id=”myBC” creationComplete=”myBC.contentGroup.clipAndEnableScrolling = true”>

即:在容器创建完成后设置它的属性contentGroup的clipAndEnableScrolling为true

原理:

BorderContainer继承自SkinnableContainer,这两个组件都不是自身添加显示对象的,而是使用contentGroup作为子内容的容器,

而contentGroup实际上是一个Group对象 Group本身有一个属性:clipAndEnableScrolling,当它为true时,就会裁剪内容,默认是false

Flex User Group文档–AIR介绍

一个很有用的PPT,用于向不了解这技术的人介绍
点击下载