Android-Multi-Touch~
忙啊忙……直接贴码了,是个挺简单的过程:
public boolean onTouch(View v, MotionEvent event)
{
for( int i = 0; i < event.getPointerCount(); i++ ){
float x = event.getX(i);
float y = event.getY(i);
}
return true;
}
只在G3 2.1Rom上测试过,其他,不知道呀么不知道~~
发现自己越来越不严谨=,=
八款开源Android游戏引擎
听说原产地是CSDN,有兴趣的自己找下原出处吧,以下是内容:
很多初学Android游戏开发的朋友,往往会显得有些无所适从,他们常常不知道该从何处入手,每当遇到自己无法解决的难题时,又往往会一边羡慕于 iPhone下有诸如Cocos2d-iphone之类的免费游戏引擎可供使用,一边自暴自弃的抱怨Android平台游戏开发难度太高,又连个像样的游 戏引擎也没有,甚至误以为使用Java语言开发游戏是一件费力不讨好且没有出路的事情。
事实上,这种想法完全是没有必要且不符合实际的,作为能和苹果iOS分庭抗礼的Android(各种意义上),当然也会有相当数量的游戏引擎存在。仅仅因为我们处于这个狭小的天地间,与外界接触不够,所以对它们的存在茫然不知罢了。
下面我就罗列出八款常见的Android游戏引擎,以供有需要者参考(收费,下载量过小,不公布源码,以及鄙人不知道(-_-)的引擎不在此列)。
1、Angle
Angle是一款专为Android平台设计的,敏捷且适合快速开发的2D游戏引擎,基于OpenGL ES技术开发。该引擎全部用Java代码编写,并且可以根据自己的需要替换里面的实现,缺陷在于文档不足,而且下载的代码中仅仅包含有少量的示例教程。
最低运行环境要求不详。
项目地址:http://code.google.com/p/angle/
2、Rokon
rokon是一款Android 2D游戏引擎,基于OpenGL ES技术开发,物理引擎为Box2D,因此能够实现一些较为复杂的物理效果,该项目最新版本为 2.0.3 (09/07/10)。总体来说,此引擎最大的优点在于其开发文档相当之完备,并且项目作者对反馈Bug的修正非常之神速,所以该框架的使用在目前也最为 广泛,有人干脆将它称为Cocos2d-iPhone引擎的Android版(业务逻辑和编码风格上也确实很像)。附带一提,国内某个需要注册会员才能下 载的Android游戏框架衍生于此框架,所以大家也不要刻板的认为收费便一定是好的,免费就一定不好。
最低运行环境要求为Android 1.5。
项目地址:http://code.google.com/p/rokon/
3、LGame
LGame是一款国人开发的Java游戏引擎,有Android及PC(J2SE)两个开发版本,目前最高版本同为0.2.6(31/07/10)。其底 层绘图器LGrpaphics封装有J2SE以及J2ME提供的全部Graphics API(PC版采用Graphics2D封装,Android版采用Canvas模拟实现),所以能够将J2SE或J2ME开发经验直接套用其中,两版本 间主要代码能够相互移植。Android版内置有Admob接口,可以不必配置XML直接硬编码Admob广告信息。
该引擎除了基本的音效、图形、物理、精灵等常用组件以外,也内置有Ioc、xml、http等常用Java组件的封装,代价是jar体积较为庞大,PC版 已突破1.2MB,Android版有所简化也在500KB左右。此外,该引擎还内置有按照1:1实现的J2ME精灵类及相关组件,可以将绝大多数 J2ME游戏平移到Android或PC版中。唯一遗憾的是,该项目作者是个极其懒惰的家伙,开发文档从去年说到今年依旧没有提供,只有游戏示例可供下 载。
最低运行环境要求为Android 1.1。
项目地址:http://code.google.com/p/loon-simple/
4、AndEngine
andengine同样是一款基于OpenGL ES技术的Android游戏引擎,物理引擎同样为Box2D(标配|||)。该框架性能普通,文档缺乏,但示例较为丰富。
下载地址(未直接提供jar下载,源码可通过svn提取):http://code.google.com/p/andengine/
最低运行环境要求不详。
项目地址:http://code.google.com/p/rokon/
5、libgdx
libgdx是一款基于OpenGL ES技术开发的Android游戏引擎,支持Android平台下的2D游戏开发,物理引擎采用Box2D实现。单就性能角度来说,堪称是一款非常强大的 Android游戏引擎,但缺陷在于精灵类等相关组件在使用上不够简化,而且文档也较为匮乏。
最低运行环境要求不详。
项目地址:http://code.google.com/p/libgdx/
6、jPCT
jPCT是一款基于OpenGL技术开发的3D图形引擎(PC环境为标准OpenGL,Android为OpenGL ES), 以Java语言为基础的,拥有功能强大的Java 3D解决方案。该引擎与LGame(此为2D游戏引擎)相类似,目前拥有PC(J2SE)以及Android两个开发版本。
jPCT的最大优势之一,就在于它惊人的向下兼容性。在PC环境中,jPCT甚至可以运行在JVM1.1环境之中,因为jPCT内部提供的图形渲染接口完 全符合所有的Java 1.1规范(就连已经消失的Microsoft VM乃至更古老的Netscape 4 VM也不例外)。
最低运行环境要求为Android 1.5。
项目地址:http://www.jpct.net/jpct-ae/
7、Alien3d
Alien3d是一款体积非常之小的Android 3D游戏引擎,基于OpenGL ES技术开发。为了压缩体积,它根据不同功能采用多jar方式发布(包括alien3d-engine.jar,alien3d- tiled.jar,alien3d-sprites.jar,alien3d-shapes.jar,alien3d- particles2d.jar,),事实上它的核心文件大约只有40KB,所有相关jar的总和也不足150KB。
最低运行环境要求为Android 1.5。
项目地址:http://code.google.com/p/alien3d/
8、Catcake
Catcake是一款跨平台的Java 3D图形引擎,目前支持PC(J2SE)及Android环境运行(已有iPhone版规划)。该引擎在易用性和运行性能上皆有出色的表现,支持常见的游戏开发功能,诸如精灵动画,音频处理和视频播放等。
最低运行环境要求为Android 1.6。
Flash全屏的那些事儿
说正事儿前也许你想要了解下这个内容:《Flash全屏后无法输入》
现在Adobe对全屏稍微做了点修改,真的是一点点修改……
相关文章在这里:Limited full-screen keyboard input
部分摘录:
Flash Player 9 does not allow keyboard input when displaying content in full-screen mode.
Flash Player 10 changes this, allowing for a limited number of keys to be usable in full-screen mode. These include Tab, the Spacebar, and the (up, down, left, right) arrow keys.
在FP9里边全屏状态下Flash是不允许和键盘输入的,当然ESC键除外。
而FP10修改之后变成了受限的全屏模式,目前只支持Tab,空格,4个箭头进行交互……
So,你要想在全屏状态下获得键盘输入,在正常情况下市不可能的。
不过昨天有个大哥发了个可以全屏厚输入的swf,所以呢,还是可行的,只是。。小弟不才,破解之后的代码搞不懂呀么搞不懂~~
The Evolution of Adobe Flash: From 1996 to 2010
越来越懒,啥都不想写……抄袭一个Flash的进化史~~
From http://www.pxleyes.com/blog/2010/07/evolution-of-flash-from-1996-to-2010/
Adobe Flash is arguably the most popular multimedia platform today. Users can watch videos, chat, and play games thanks to the capabilities of the Flash player. Content creators are afforded almost unlimited power due to ActionScript 3′s powerful features.
Flash wasn’t always the rich and advanced platform it is today, however. It started as a vector animation package named FutureSplash Animator in 1996 and 14 years later, it’s going strong, with a desktop, mobile, and server-side presence.
FutureSplash Animator – 1996

The first version of Flash, called FutureSplash Animator, was created by Jon Gay and Charlie Jackson, co-founders of FutureWave software. It was the animation extension of FutureWave’s SmartSketch, a vector drawing application. The first version of FutureSplash Animator was shipped in 1996 and a mere 7 months later, Macromedia bought FutureWave and renamed FutureSplash to simply Flash.

《程序员》精彩推荐:Android程序创意过滤与失败经验谈
via www.programmer.com.cn on 7/21/10 文/ 刘铁锋
从2008年底开始,我就在Android上进行程序开发探索。随着时间的推移,我越来越不敢妄自预测或者假设程序创意一定会成功,更多地发现用户的期望以及需求和事先预想很难一致。在一年半的开发过程中,尝试了各种不同的方法和思路来进行程序创意规划和试错。至今,依然失败的教训居多,侥幸成功的很少。因此,我将在本文中分享所经历的创意过滤经验以及失败教训。
思路转换的失败
在转入Android开发时,我的相关工作经验都是在大型基础平台上做程序开发。针对的用户群体动辄就是全球目标用户,在商业判断和分析上,最基础的一个考量就是用户群体和业务模式的总量的收益是否足够大,对用户群体的研究和商业判断分析完全根据市场分析报告和数据来做判断。因此,不可避免地在程序创意思路上会沿用以前的工作思路和分析方法。
在考虑Android上的创意的同时,不自觉地就考虑和分析了如下几个方面的问题:
1. 是否为用户所必需?
2. 技术上是否领先?
3. 程序的粘性是否足够?
4. 用户群体是否足够大?
因此,沿用这个思路,不可避免地就会往大的应用和大的服务上去思考和做出判断。
经过多方的讨论,找到了一个切入点:在用户联系人信息上同时显示出用户在社会网络(比如Facebook/Twitter)上的同步更新,并加上相关的操作是不错的想法。
理由如下:
1. 联系人是手机用户需要的必不可少的功能,绝对必须使用。
2. 技术上由于需要实现和系统联系人类似的功能,工作量不会小。如果加上未来在云端的备份,技术门槛也不会太低。
3. 绑定用户的社会网络信息,这个粘性理论上和用户使用社会网络的粘性一样。
4. 用户群体为所有社交网络的用户,考虑到Google手机的用户都是技术的爱好者和早期技术推广者,那么,基本上大部分Android用户都会使用。
按照这个思考方式分析下来,毫无疑问,这个想法一点也不差,能够相当完美地达到预期的规划。
因此,我们投入了3位开发工程师和1位产品经理,一共工作了3个月的时间,产品才初步成型,产品的源代码接近2MB,最后编译出来的程序接近4MB。
经过了痛苦的研发过程,产品出来之后,结果却令人大跌眼镜:
1. 程序包过大。用户根本不愿意下载,下载量非常惨淡。
2. 用户完全搞不懂这个程序的目的和用法。程序的命令以及描述非常难表达,并且程序需要绑定用户的社交网络账号,才可以显示信息。没有绑定之前,看不到任何特别信息,也体会不到程序的作用。很多用户在上手时看到需要绑定,便开始疑惑了。
3. 最终有用户搞明白了程序的用法,觉得想法不错。但程序的稳定性和性能遇到的了严重的瓶颈。尽管在其他平台开发经验不错,但是毕竟这是一个新的平台,并且程序操作相当复杂,用户依然选择了放弃使用。
4. 下载量不高,评分又逐渐降低,程序就在排行榜的榜单上渐渐消失了。
5. 惨淡的结果,让所有参与人员都开始沮丧,觉得这并不是一个好的想法。后来在iPhone上发现了类似的程序,从销售情况来看,表现同样不够好。再后来,Moto的Cliq基本上完整地把这个想法实现了,并作为一重大创新和卖点进行推出。
经过反复地反省和对比,初步得出了这样的失败教训:
1. 对于个人开发者和小型团队来说,不适合做过于基础的程序。操作的模式和理念上的创新与用户的接受度有相当的距离。这样的事情只有大公司才有财力和可能进行推广。比如说手机生产商,他们可以通过预置的方式进行推广。而对个人开发者来说,得先证明你的想法是成功的,不能假设一个会成功的需求和应用,然后卖给设备厂商。
2. 个人开发者和小型团队不适合做大的程序,尤其是开发时间不要超过2个月。4个人,3个月的时间,对于一个小团队来说 ,是相当宝贵的。这不仅仅是时间和金钱的问题,更多的是信心问题。
3. 用户能否真正接受你的想法,是一个关键性的问题。设想和推导都很完美,唯独缺了用户是否真正喜欢和接受这一条,又没有方法进行快速地验证和试错,基本上不能成功。
因此,在开发者头脑风暴产生一个创意之后,要做的几个最主要的过滤在于:
1. 开发时间是否太长?
2. 开发的技术难度是否会过高,而导致不能实现或者质量不可靠?
3. 有怎样的办法来判断用户是否会喜欢?
有了这几个过滤条件,相信能够减少失败的几率,或者说能够Fail Fast(尽快失败),从而减少损失。
技术门槛的失败
在Android开发的过程中,除了大型的程序探索,我们也研究了些小程序来练手。有个同事提出Android上删除程序不方便,于是,找人花一天左右的时间做了一个叫Quick Uninstaller的程序。程序非常简单,启动之后显示所有程序图标,双击程序图标,即可删除该程序。想法以及难度,都不很独特。
但是,效果却出乎大家的意料。用户好评如潮,由于功能比较简单,用户基本上无需学习,加上又是先行者,产品质量非常稳定,没有任何“force close”(Android程序出现异常或者等待时间过长,会弹出“force close”的对话框)。用户毫不犹豫地直接打出5分,并且基本上没有任何低分出现过。
但是,好景不长。在一次Google清洗的过程中,因为一些版权问题,账号被Google封掉了。所有程序被强行下架。这个时候,竞争对手迅速上位,就是目前在排行榜前列的Uninstaller,而我们的程序则一落千丈,尽管现在在某个细分分类中还有一定的位置,但是相比排名最高的程序,已经相差很远了。
这也让我们多了一个失败的教训:
1. 技术门槛不高,不能保证你一直保持优势。对你来说简单的程序,对竞争对手来说,程序同样的简单。因此,你能做,别人也能做。在这一点上,其实竞争同样激烈。
2. 封账号的代价相当之大,基本上等于你的努力悉数尽毁。Don’t do evil。
因此,在这个案例中,增加了一个新的创意过滤条件:
程序的创意是否过于简单?如果过于简单,那么创意能够始终保持成功的机会不会太高。
依赖第三方资源的失败
在经历了前面的屡次失败之后,我们开始做些研究的工作。发现老外其实也很八卦,什么笑话、娱乐新闻等,接受程度很高。因此,我们就想到了FML(Fuck My Life)的网站,也就是老外比较热衷的糗事分享网站,每天有很多人会发布各种各样的糗事,文字最后均会以Fuck My Life结尾。
于是,想到如果在手机上有这样的客户端,用户可能会更加愿意用,尤其是在发生糗事的时候,忍不住就想分享出来,粘性也会足够。
基于以上考虑,我们投入力量,实现了一个功能比较完善的版本,不仅融合了此服务所应有的相关功能,同时还花了不少工夫,加上了好多自定义的功能。
经过一段时间的努力,在Entertainment分类上,排名进了前10名,印象中程序最好排到了第3名。
好景不长在,失败总会有。
这个时候,FML的官网发现了这个机会。他们觉得这是一个很好的想法,应该自己在Market上发布自己的官方程序。于是,他们干了这样的事情来清除竞争对手。他们直接向Google举报,说其它程序没有得到他们的授权。一次举报,竞争对手全部清干净了,于是他们的官方程序上线了。
这一次,得到了一个更加深刻的教训:
1. 不要过于依赖第三方资源。依赖第三方资源或者网站的名气,的确可能帮助你的程序受到很多关注,代价也同样存在,一旦人家开始动手举报,你连还手的机会都没有。
2. 不要选错第三方资源。很多的服务提供商是不开放的,尽管他们没有明确说明。同时还有很多服务提供商是充分开放的,比如Twitter就是一个非常开放的例子。选错了第三方资源,结果一样会失败。
因此,这里又多了一个创意过滤的条件:
是否依赖于第三方资源? 如果是,请尽快绕道离开,因为很难靠这个想法走太远。
胡乱模仿的失败
由于才疏学浅和关注面单一,想法总会有用完的时候。在尝试了很多自己的想法之后,很多人都会有想法来借鉴或者说抄袭App Store上排名靠前的程序。
但是,以我的经验和分析来看,这条路基本上不可行。
有以下几个方面的原因:
1. 画虎不成反类犬。如果是在人家创意上进行的功能改进,你还可能有一定的突破和机会。如果仅仅是抄袭,由于平台的不同,Android的控件和iPhone的程序控件相差太远,哪怕做出来程序类似,操作体验和程序的精致程度也和iPhone上程序相差甚远,往往就成为画虎不成反类犬。
2. 版权问题。老外的版权意识非常强,不仅仅是原作者非常关心,用户也很敏感。如果侥幸程序排到了前列,不仅会把原作者招惹过来,用户还会出来举报。一旦Google收到了举报邮件,基本上是杀无赦。反倒是偷鸡不成蚀把米。
因此,创意过滤中又多了一个条件:
创意是否有版权争议?如果是,尽快停止。失败只是时间的问题。
其他
总的来说,在我的探索过程中,成功的少,而失败的太多太多。在与Google打交道的过程中,依然有很多失败的教训可供分享。
1. Don’t do evil。美国人做事的方式非常直接,同时会默认你是善意的。对于Google来说,尤其如此。因此,在我尝试过的程序中,你可以任意发布你的程序到Google Market。但是,如果涉及到版权纠纷,不管是网站的所有者、原程序的开发者还是其它任何一种类型的版权纠纷,一旦举报到Google,轻者下架单个程序,重者封禁整个账号,并且下架所有程序。也就是说,一旦受到处罚,你就别想翻身了。因此,Don’t do evil。
2. Google的审查底线。尽管Google不做审查,但除了和版权争议相关的程序之外,哪怕是你自己的程序,依然有如下的禁区是不能碰的:
a. 不要使用任何Google相关的名义。程序名、开发者名都不能涉及到Google或者看起来类似Google的名称,否则Google不会予以通过。
b. 不要违反任何Google的开发者协议。需要仔细阅读Google的开发者协议,在不同时候Google的开发者协议会经常更新。因此,只要违反了任何Google开发者协议,当Google处罚到你的时候,基本上没有申辩机会。因此,务必要小心。
总结
在我开发的经验过程中,成功的经验不多,而失败的教训无数。哪怕如此,我坚信在移动互联网领域,依然存在这样或者那样的机会。也许不经意间你的一个创意就得到了用户的热捧,有幸跑到排行榜的前列,但是这需要足够多的精力和耐性来打磨你的产品,才不至于昙花一现。同时,也不能得意忘形,说不好,就会有各种各样的可能导致你失去优势。因此,移动领域的确是一个新的机会,但绝对不是一个能够随随便便抓住的机会。希望我的失败教训能够帮助到开发者,以此为鉴。
作者简介:刘铁锋,曾供职于微软亚洲研究院搜索技术中心,目前从事移动设备软件相关开发工作,关注Android、iPhone等相关开发技术以及App Store、Android Market等业界应用商店进展。
(本文来自《程序员》杂志10年05期)
《程序员》10年7月刊精彩内容预告:http://www.programmer.com.cn/3484/
《程序员》订阅:http://book.csdn.net/programmer/
-------------------------------------------------------------------------------------------------
最新有点忙,先转载了~~
16 Useful Mathematical Formulas In ActionScript 3
From http://ntt.cc/2010/07/06/16-useful-mathematical-formulas-in-actionscript-3.html
1. Distance Between Two Points
dx = x2 – x1; dy = y2 – y1; dist = Math.sqrt(dx*dx + dy*dy);
2. Inching Formulas
sprite.x += (targetX - sprite.x) * easing;//easing: inching coefficient sprite.y += (targetY - sprite.y) * easing;
3. Elastic Formulas
vx += (targetX - sprite.x) * spring; //spring: elastic coefficient vy += (targetY - sprite.y) * spring; sprite.x += (vx *= friction); //friction: friction force sprite.y += (vy *= friction);
4. Flexible Partial Shifts Formulas
var dx:Number = sprite.x - fixedX; var dy:Number = sprite.y - fixedY; var angle:Number = Math.atan2(dy, dx); var targetX:Number = fixedX + Math.cos(angle) * springLength; var targetY:Number = fixedX + Math.sin(angle) * springLength;
5. Rotation With Mouse Formulas
dx = mouseX - sprite.x; dy = mouseY - sprite.y; sprite.rotation = Math.atan2(dy, dx) * 180 / Math.PI;
6. Waveform Formulas
public function onEnterFrame1(event:Event):void {
ball.y=centerScale+Math.sin(angle)*range;
angle+=speed;
}
7. Heartthrob Formulas
public function onEnterFrame1(event:Event):void {
ball.scaleX=centerScale+Math.sin(angle)*range;
ball.scaleY=centerScale+Math.sin(angle)*range;
angle+=speed;
}
8. Circle Rotation Formulas
public function onEnterFrame(event:Event):void {
ball.x=centerX+Math.cos(angle)*radius;
ball.y=centerY+Math.sin(angle)*radius;
angle+=speed;
}
9. Get Circle Area
public function getArea():Number
{
// The formula is Pi times the radius squared.
return Math.PI * Math.pow((width / 2), 2);
}
10. Get Circumference Ratio
public function getCircumference():Number
{
// The formula is Pi times the diameter.
return Math.PI * width;
}
11. Elliptic Rotation Formulas
public function onEnterFrame(event:Event):void {
ball.x=centerX+Math.cos(angle)*radiusX;
ball.y=centerY+Math.sin(angle)*radiusY;
angle+=speed;
}
12. Color operations
var t:uint=0×77ff8877 var s:uint=0xff000000 var h:uint=t&s var m:uint=h>>>24 trace(m);
13. Hex to Decimal
trace(hexValue);
14. Decimal to Hex
decimalValue.toString(16);
15. Pick Up Color
red = color24 >> 16; green = color24 >> 8 & 0xFF; blue = color24 & 0xFF; alpha = color32 >> 24; red = color32 >> 16 & 0xFF; green = color32 >> 8 & 0xFF; blue = color232 & 0xFF;
16. Color Bit Arithmetic
color24 = red << 16 | green << 8 | blue; color32 = alpha << 24 | red << 16 | green << 8 | blue;
Admob-Mobile advertising and the iPhone
From http://blog.admob.com/2010/06/09/mobile-advertising-and-the-iphone/
Apple proposed new developer terms on Monday that, if enforced as written, would prohibit app developers from using AdMob and Google’s advertising solutions on the iPhone. These advertising related terms both target companies with competitive mobile technologies (such as Google), as well as any company whose primary business is not serving mobile ads. This change threatens to decrease – or even eliminate – revenue that helps to support tens of thousands of developers. The terms hurt both large and small developers by severely limiting their choice of how best to make money. And because advertising funds a huge number of free and low cost apps, these terms are bad for consumers as well.
Let’s be clear. This change is not in the best interests of users or developers. In the history of technology and innovation, it’s clear that competition delivers the best outcome. Artificial barriers to competition hurt users and developers and, in the long run, stall technological progress.
Since I started AdMob in 2006, I have watched competition in mobile advertising help drive incredible growth and innovation in the overall ecosystem. We’ve worked to help developers make money, regardless of platform – iPhone, Android, Palm Pre, Blackberry, Windows, and others. In the past four years, AdMob has helped tens of thousands of developers make money and build real businesses across multiple operating systems.
I’ve personally worked with many iPhone app developers around the world, including one who created a fun and simple game in the early days of the App Store. He built the app because he was interested in the challenge. He built this single app into a multi-million dollar advertising revenue stream with AdMob, hired a whole team, and turned a hobby into a real business.
We see these stories all the time. We want to help make more of them, so we’ll be speaking to Apple to express our concerns about the impact of these terms.
Omar
-----------------------------------------------------------------------------
应该要被告垄断了吧,水果,越来越专制了。
Security Advisory for Flash Player, Adobe Reader and Acrobat
From Security Advisory for Flash Player, Adobe Reader and Acrobat
Release date: June 4, 2010
Last updated: June 8, 2010
Vulnerability identifier: APSA10-01
CVE number: CVE-2010-1297
Platform: All
Summary
A critical vulnerability exists in Adobe Flash Player 10.0.45.2 and earlier versions for Windows, Macintosh, Linux and Solaris operating systems, and the authplay.dll component that ships with Adobe Reader and Acrobat 9.x for Windows, Macintosh and UNIX operating systems. This vulnerability (CVE-2010-1297) could cause a crash and potentially allow an attacker to take control of the affected system. There are reports that this vulnerability is being actively exploited in the wild against both Adobe Flash Player, and Adobe Reader and Acrobat.
We are in the process of finalizing a fix for the issue, and expect to provide an update for Flash Player 10.x for Windows, Macintosh, and Linux by June 10, 2010. The patch date for Flash Player 10.x for Solaris is still to be determined. We expect to provide an update for Adobe Reader and Acrobat 9.3.2 for Windows, Macintosh and UNIX by June 29, 2010. Please note that the Acrobat and Reader update represents an accelerated release of the next quarterly security update originally scheduled for July 13, 2010. With this accelerated scheduled we do not plan to release any new updates for Adobe Reader and Acrobat on July 13, 2010.
Affected software versions
Adobe Flash Player 10.0.45.2, 9.0.262, and earlier 10.0.x and 9.0.x versions for Windows, Macintosh, Linux and Solaris
Adobe Reader and Acrobat 9.3.2 and earlier 9.x versions for Windows, Macintosh and UNIX
Note:
The Flash Player 10.1 Release Candidate available at http://labs.adobe.com/technologies/flashplayer10/ is confirmed not vulnerable.
Adobe Reader and Acrobat 8.x are confirmed not vulnerable.
MItigations
Adobe Flash Player
The Flash Player 10.1 Release Candidate available at http://labs.adobe.com/technologies/flashplayer10/ is confirmed not vulnerable.
Adobe Reader and Acrobat - Windows
Deleting, renaming, or removing access to the authplay.dll file that ships with Adobe Reader 9.x and Acrobat 9.x mitigates the threat for those products, but users will experience a non-exploitable crash or error message when opening a PDF file that contains SWF content.
The authplay.dll that ships with Adobe Reader 9.x and Acrobat 9.x for Windows is typically located at C:\Program Files\Adobe\Reader 9.0\Reader\authplay.dll for Adobe Reader or C:\Program Files\Adobe\Acrobat 9.0\Acrobat\authplay.dll for Acrobat.
AS3-Water ripples
这是国外某友人在08年弄的一个东西,今天刚好在reader里看到,分享下吧:http://www.derschmale.com/2008/08/03/water-ripples-revisited-as3-only-version/
Demo:
Rippler.as:
/*
Copyright (c) 2008 NascomASLib Contributors. See:
http://code.google.com/p/nascomaslib
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package be.nascom.flash.graphics
{
import flash.display.BitmapData;
import flash.display.BitmapDataChannel;
import flash.display.BlendMode;
import flash.display.DisplayObject;
import flash.events.Event;
import flash.filters.ConvolutionFilter;
import flash.filters.DisplacementMapFilter;
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.geom.Rectangle;
/**
*
* The Rippler class creates an effect of rippling water on a source DisplayObject.
*
* @example The following code takes a DisplayObject on the stage and adds a ripple to it, assuming source is a DisplayObject already on the stage.
*
* <listing version="3.0">
* import be.nascom.flash.graphics.Rippler;
*
* // create a Rippler instance to impact source, with a strength of 60 and a scale of 6.
* // The source can be any DisplayObject on the stage, such as a Bitmap or MovieClip object.
* var rippler : Rippler = new Rippler(source, 60, 6);
*
* // create a ripple with size 20 and alpha 1 with origin on position (200, 50)
* rippler.drawRipple(100, 50, 20, 1);
* </listing>
*
* @author David Lenaerts
* @mail david.lenaerts@nascom.be
*
*/
public class Rippler
{
// The DisplayObject which the ripples will affect.
private var _source : DisplayObject;
// Two buffers on which the ripple displacement image will be created, and swapped.
// Depending on the scale parameter, this will be smaller than the source
private var _buffer1 : BitmapData;
private var _buffer2 : BitmapData;
// The final bitmapdata containing the upscaled ripple image, to match the source DisplayObject
private var _defData : BitmapData;
// Rectangle and Point objects created once and reused for performance
private var _fullRect : Rectangle; // A buffer-sized Rectangle used to apply filters to the buffer
private var _drawRect : Rectangle; // A Rectangle used when drawing a ripple
private var _origin : Point = new Point(); // A Point object to (0, 0) used for the DisplacementMapFilter as well as for filters on the buffer
// The DisplacementMapFilter applied to the source DisplayObject
private var _filter : DisplacementMapFilter;
// A filter causing the ripples to grow
private var _expandFilter : ConvolutionFilter;
// Creates a colour offset to 0x7f7f7f so there is no image offset due to the DisplacementMapFilter
private var _colourTransform : ColorTransform;
// Used to scale up the buffer to the final source DisplayObject's scale
private var _matrix : Matrix;
// We only need 1/scale, so we keep it here
private var _scaleInv : Number;
/**
* Creates a Rippler instance.
*
* @param source The DisplayObject which the ripples will affect.
* @param strength The strength of the ripple displacements.
* @param scale The size of the ripples. In reality, the scale defines the size of the ripple displacement map (map.width = source.width/scale). Higher values are therefor also potentially faster.
*
*/
public function Rippler(source : DisplayObject, strength : Number, scale : Number = 2)
{
var correctedScaleX : Number;
var correctedScaleY : Number;
_source = source;
_scaleInv = 1/scale;
// create the (downscaled) buffers and final (upscaled) image data, sizes depend on scale
_buffer1 = new BitmapData(source.width*_scaleInv, source.height*_scaleInv, false, 0x000000);
_buffer2 = new BitmapData(_buffer1.width, _buffer1.height, false, 0x000000);
_defData = new BitmapData(source.width, source.height, false, 0x7f7f7f);
// Recalculate scale between the buffers and the final upscaled image to prevent roundoff errors.
correctedScaleX = _defData.width/_buffer1.width;
correctedScaleY = _defData.height/_buffer1.height;
// Create reusable objects
_fullRect = new Rectangle(0, 0, _buffer1.width, _buffer1.height);
_drawRect = new Rectangle();
// Create the DisplacementMapFilter and assign it to the source
_filter = new DisplacementMapFilter(_defData, _origin, BitmapDataChannel.BLUE, BitmapDataChannel.BLUE, strength, strength, "wrap");
_source.filters = [_filter];
// Create a frame-based loop to update the ripples
_source.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
// Create the filter that causes the ripples to grow.
// Depending on the colour of its neighbours, the pixel will be turned white
_expandFilter = new ConvolutionFilter(3, 3, [0.5, 1, 0.5, 1, 0, 1, 0.5, 1, 0.5], 3);
// Create the colour transformation based on
_colourTransform = new ColorTransform(1, 1, 1, 1, 128, 128, 128);
// Create the Matrix object
_matrix = new Matrix(correctedScaleX, 0, 0, correctedScaleY);
}
/**
* Initiates a ripple at a position of the source DisplayObject.
*
* @param x The horizontal coordinate of the ripple origin.
* @param y The vertical coordinate of the ripple origin.
* @param size The size of the ripple diameter on first impact.
* @param alpha The alpha value of the ripple on first impact.
*/
public function drawRipple(x : int, y : int, size : int, alpha : Number) : void
{
var half : int = size >> 1; // We need half the size of the ripple
var intensity : int = (alpha*0xff & 0xff)*alpha; // The colour which will be drawn in the currently active buffer
// calculate and draw the rectangle, having (x, y) in its centre
_drawRect.x = (-half+x)*_scaleInv;
_drawRect.y = (-half+y)*_scaleInv;
_drawRect.width = _drawRect.height = size*_scaleInv;
_buffer1.fillRect(_drawRect, intensity);
}
/**
* Returns the actual ripple image.
*/
public function getRippleImage() : BitmapData
{
return _defData;
}
/**
* Removes all memory occupied by this instance. This method must be called before discarding an instance.
*/
public function destroy() : void
{
_source.removeEventListener(Event.ENTER_FRAME, handleEnterFrame);
_buffer1.dispose();
_buffer2.dispose();
_defData.dispose();
}
// the actual loop where the ripples are animated
private function handleEnterFrame(event : Event) : void
{
// a temporary clone of buffer 2
var temp : BitmapData = _buffer2.clone();
// buffer2 will contain an expanded version of buffer1
_buffer2.applyFilter(_buffer1, _fullRect, _origin, _expandFilter);
// by substracting buffer2's old image, buffer2 will now be a ring
_buffer2.draw(temp, null, null, BlendMode.SUBTRACT, null, false);
// scale up and draw to the final displacement map, and apply it to the filter
_defData.draw(_buffer2, _matrix, _colourTransform, null, null, true);
_filter.mapBitmap = _defData;
_source.filters = [_filter];
temp.dispose();
// switch buffers 1 and 2
switchBuffers();
}
// switch buffer 1 and 2, so that
private function switchBuffers() : void
{
var temp : BitmapData;
temp = _buffer1;
_buffer1 = _buffer2;
_buffer2 = temp;
}
}
}
PHP-DOMDocument读取XML
唉,啥都不说了,,,尝试来尝试去,发现PHP还真是个纠结的东西。
示例代码,xml地址用的douban的开放api,哦,老刷新不到的,很不靠谱~
< ?php
$xml ="http://api.douban.com/people/letusrock/events/initiate";
$dom = new DOMDocument();
$dom->load($xml);
$xml_value = $dom->getElementsByTagName('entry');
$total = $xml_value->length;
for($i=0;$i< $total;$i++){
echo "活动标题:",$xml_value->item($i)->getElementsByTagName("title")->item(0)->nodeValue,"<br />";
}
echo "总活动数:",$total;
?>
The Google Font Directory & Google Font API
The Google Font Directory lets you browse all the fonts available via the Google Font API. All fonts in the directory are available for use on your website under an open source license and served by Google servers. You can use them on any non-commercial or commercial project.
You don’t need to do any programming; all you have to do is add a special stylesheet link to your HTML document, then refer to the font in a CSS style. The Google Font API is compatible with Google Chrome 4.249.4+, Firefox 3.5+, Safari 3.1+ andIE 6+. However, The Google Font API is not currently supported on iPhone, iPad, iPod, or Android.
啥都不说了,不知道中文字体库有没机会做到里边……
AS3-LightOut
来个LightOut小游戏,至于LightOut是啥,可以看这里:http://en.wikipedia.org/wiki/Lights_Out_%28game%29
如果该页面被和谐,那可以看下@dfdou的简单介绍,LightOut是一个开/关游戏,游戏的目的很简单,在5x5的的方阵里,把全部的图换成亮着的状态就过关了,Demo里是白色方块代表亮起状态。
规则是点击一个方块,在方块4周的4个方块和方块本身的状态会发生改变,是亮起就变成关掉,是关掉就变成亮起~
Demo在这里:
下边来讲下代码部分,比较简单,3个类搞定。
AS3-Key Control Codes Define Class
先来看下这个:http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/ui/Keyboard.html
这里边是AIR里的键盘对应类,不过很奇怪的是有些STRING_F32 : String = "?"的格式
F32算是保留键,不过STRING_DOWNARROW : String = "?"这个就很奇怪了,这个是啥键,不是小键盘的向下键?
Flash就没这么好命了,你只能自己写键盘对应的键值,不过有好人把对应键整理了出来,原地址是在这里:http://ntt.cc/2010/05/03/flash-key-control-codes-define-class.html
Copy下:
package {
public class KeyControlCode {
public static var KEY_BACKSPACE:uint=8;
public static var KEY_TAB:uint=9;
public static var KEY_ENTER:uint=13;
public static var KEY_SHIFT:uint=16;
public static var KEY_CONTROL:uint=17;
public static var KEY_PAUSE:uint=19;
public static var KEY_CAPSLOCK:uint=20;
public static var KEY_ESC:uint=27;
public static var KEY_SPACEBAR:uint=32;
public static var KEY_PAGEUP:uint=33;
public static var KEY_PAGEDOWN:uint=34;
public static var KEY_END:uint=35;
public static var KEY_HOME:uint=36;
public static var KEY_LEFT:uint=37;
public static var KEY_UP:uint=38;
public static var KEY_RIGHT:uint=39;
public static var KEY_DOWN:uint=40;
public static var KEY_INSERT:uint=45;
public static var KEY_DELETE:uint=46;
public static var KEY_0:uint=48;
public static var KEY_1:uint=49;
public static var KEY_2:uint=50;
public static var KEY_3:uint=51;
public static var KEY_4:uint=52;
public static var KEY_5:uint=53;
public static var KEY_6:uint=54;
public static var KEY_7:uint=55;
public static var KEY_8:uint=56;
public static var KEY_9:uint=57;
public static var KEY_A:uint=65;
public static var KEY_B:uint=66;
public static var KEY_C:uint=67;
public static var KEY_D:uint=68;
public static var KEY_E:uint=69;
public static var KEY_F:uint=70;
public static var KEY_G:uint=71;
public static var KEY_H:uint=72;
public static var KEY_I:uint=73;
public static var KEY_J:uint=74;
public static var KEY_K:uint=75;
public static var KEY_L:uint=76;
public static var KEY_M:uint=77;
public static var KEY_N:uint=78;
public static var KEY_O:uint=79;
public static var KEY_P:uint=80;
public static var KEY_Q:uint=81;
public static var KEY_R:uint=82;
public static var KEY_S:uint=83;
public static var KEY_T:uint=84;
public static var KEY_U:uint=85;
public static var KEY_V:uint=86;
public static var KEY_W:uint=87;
public static var KEY_X:uint=88;
public static var KEY_Y:uint=89;
public static var KEY_Z:uint=90;
public static var KEY_NUMPAD_0:uint=96;
public static var KEY_NUMPAD_1:uint=97;
public static var KEY_NUMPAD_2:uint=98;
public static var KEY_NUMPAD_3:uint=99;
public static var KEY_NUMPAD_4:uint=100;
public static var KEY_NUMPAD_5:uint=101;
public static var KEY_NUMPAD_6:uint=102;
public static var KEY_NUMPAD_7:uint=103;
public static var KEY_NUMPAD_8:uint=104;
public static var KEY_NUMPAD_9:uint=105;
public static var KEY_NUMPAD_MULTIPLY:uint=106;
public static var KEY_PLUS:uint=107;
public static var KEY_SUBTRACT:uint=109;
public static var KEY_DOT:uint=110;
public static var KEY_DIVISION:uint=111;
public static var KEY_F1:uint=112;
public static var KEY_F2:uint=113;
public static var KEY_F3:uint=114;
public static var KEY_F4:uint=115;
public static var KEY_F5:uint=116;
public static var KEY_F6:uint=117;
public static var KEY_F7:uint=118;
public static var KEY_F8:uint=119;
public static var KEY_F9:uint=120;
public static var KEY_F11:uint=122;
public static var KEY_F12:uint=123;
public static var KEY_F13:uint=124;
public static var KEY_F14:uint=125;
public static var KEY_F15:uint=126;
public static var KEY_NUMLOCK:uint=144;
public static var KEY_SCROLLLOCK:uint=145;
public static var KEY_SEMICOLON:uint=186;
public static var KEY_EQUAL:uint=187;
public static var KEY_COMMA:uint=188;
public static var KEY_MINUS:uint=189;
public static var KEY_PERIOD:uint=190;
public static var KEY_SLASH:uint=191;
public static var KEY_BACKQUOTE:uint=192;
public static var KEY_LEFTBRACKET:uint=219;
public static var KEY_BACKSLASH:uint=220;
public static var KEY_RIGHTBRACKET:uint=221;
public static var KEY_QUOTE:uint=222;
}
}
用法很简单,以前需要记键值,现在就用这里的键名就好了~感谢整理出来的那哥们。
Android-AS3的AStar复刻版
因为需要,所以直接把AS3版本的AStar复刻成了Java版,基本上什么都没改。
唉,让人比较无语的是Java里的ArrayList和Array咩有shift和unshift之类的常用函数的?
问了班里几个似乎在做Java的人,得到的答案=没有答案。
下边是复刻之后的代码:
AStar.java:
/**
*
*/
package util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import android.util.Log;
/**
* @author DFdou
*
*/
public class AStar {
// 待考察表
private ArrayList<node> _open = new ArrayList</node><node>();
// 已考察表
private ArrayList</node><node> _closed = new ArrayList</node><node>();
// 网格
private Grid _grid;
// 开始节点
private Node _startNode;
// 结束节点
private Node _endNode;
// 终点节点的数组
private ArrayList</node><node> _path = new ArrayList</node><node>();
// 曼哈顿估价函数,算横竖距离和
//private Function _heuristic = manhattan;
// 几何估价法,算直线距离
// private var _heuristic:Function = euclidian;
// 对角线估价法
// private var _heuristic:Function=diagonal;
// 直线前进代价
private float _straightCost = 1.0f;
// 对角线前进代价
private float _diagCost = 1.414f;
public AStar() {
}
// 8方向
public boolean findPath(Grid grid) {
_grid = grid;
// 创建待考察列表
_open.clear();
// 创建已考察列表
_closed.clear();
// 起点
_startNode = _grid.getStartNode();
// 终点
_endNode = _grid.getEndNode();
_startNode.g = 0;
// 选一个估价函数,传入起点
_startNode.h = manhattan(_startNode);
_startNode.f = _startNode.g + _startNode.h;
// 返回寻路结果
return search();
}
public boolean search() {
// 将起点节点设为当前节点
Node node = _startNode;
// 如果木有到达目标节点
while (node != _endNode) {
// 循环的节点范围,不需要检测grid范围以外的节点
int startX = Math.max(0, node.x - 1);
int endX = Math.min(_grid.getNumCols() - 1, node.x + 1);
int startY = Math.max(0, node.y - 1);
int endY = Math.min(_grid.getNumRows() - 1, node.y + 1);
for (int i = startX; i < = endX; i++) {
for (int j = startY; j <= endY; j++) {
// 尝试节点
Node test = _grid.getNode(i, j);
// 尝试节点为当前节点,或者为不可通过的节点,或者临接节点都不能通过那么就跳过该节点
if (test == node || !test.walkable
|| !_grid.getNode(node.x, test.y).walkable
|| !_grid.getNode(test.x, node.y).walkable) {
continue;
}
float cost = _straightCost;
// 如果不在同直线距离上,就是对角线了~
if (!((node.x == test.x) || (node.y == test.y))) {
cost = _diagCost;
}
// 计算g值
double g = node.g + cost * test.costMultiplier;
// 计算h值
double h = manhattan(test);
// 相加得到f
double f = g + h;
// 如果测试点已经在待考察列表或者已考察列表里,就比较已考察的结果是否比当前结果大,是的话就重新赋值,也就是说找到了更优的点
if (isOpen(test) || isClosed(test)) {
if (test.f > f) {
test.f = f;
test.g = g;
test.h = h;
test.parent = node;
}
// 测试点不再待考察列表中,赋值,设置父节点,加入待考察列表
} else {
test.f = f;
test.g = g;
test.h = h;
test.parent = node;
_open.add(test);
}
}
}
// 根据f进行排序,最后一个是f值最小的
// _open.sortOn("f", Array.NUMERIC);
Comparator comp = new NodeFComparator();
Collections.sort(_open, comp);
// 作为当前节点
// node = _open.shift();
node = _open.get(0);
_open.remove(0);
_open.trimToSize();
}
buildPath();
return true;
}
// 4方向
public boolean findPath4(Grid grid) {
_grid = grid;
// 创建待考察列表
_open.clear();
// 创建已考察列表
_closed.clear();
// 起点
_startNode = _grid.getStartNode();
// 终点
_endNode = _grid.getEndNode();
_startNode.g = 0;
// 选一个估价函数,传入起点
_startNode.h = manhattan(_startNode);
_startNode.f = _startNode.g + _startNode.h;
// 返回寻路结果
return search4();
}
public boolean search4() {
// 将起点节点设为当前节点
Node node = _startNode;
// 如果木有到达目标节点
while (node != _endNode) {
// 循环的节点范围,不需要检测grid范围以外的节点
int startX = Math.max(0, node.x - 1);
int endX = Math.min(_grid.getNumCols() - 1, node.x + 1);
int startY = Math.max(0, node.y - 1);
int endY = Math.min(_grid.getNumRows() - 1, node.y + 1);
for (int i = startX; i < = endX; i++) {
for (int j = startY; j <= endY; j++) {
// 尝试节点
Node test = _grid.getNode(i, j);
// 尝试节点为当前节点,或者为不可通过的节点,或者临接节点都不能通过那么就跳过该节点
// PS:在四方向寻路情况下跳过对角线点
if (test == node || !test.walkable
|| !_grid.getNode(node.x, test.y).walkable
|| !_grid.getNode(test.x, node.y).walkable
|| Math.abs(i - node.x) + Math.abs(j - node.y) > 1) {
continue;
}
float cost = _straightCost;
// 如果不在同直线距离上,就是对角线了~
if (!((node.x == test.x) || (node.y == test.y))) {
cost = _diagCost;
}
// 计算g值
double g = node.g + cost * test.costMultiplier;
// 计算h值
double h = manhattan(test);
// 相加得到f
double f = g + h;
// 如果测试点已经在待考察列表或者已考察列表里,就比较已考察的结果是否比当前结果大,是的话就重新赋值,也就是说找到了更优的点
if (isOpen(test) || isClosed(test)) {
if (test.f > f) {
test.f = f;
test.g = g;
test.h = h;
test.parent = node;
}
// 测试点不再待考察列表中,赋值,设置父节点,加入待考察列表
} else {
test.f = f;
test.g = g;
test.h = h;
test.parent = node;
_open.add(test);
}
}
}
// 当前节点已经考察过了,所以就加入已考察列表
_closed.add(node);
// 检查待考察表里面有没有节点,没有就意味着没有可行的路径
if (_open.size() == 0) {
return false;
}
// 根据f进行排序,最后一个是f值最小的
// _open.sortOn("f", Array.NUMERIC);
Comparator comp = new NodeFComparator();
Collections.sort(_open, comp);
// 作为当前节点
// node = _open.shift();
node = _open.get(0);
_open.remove(0);
_open.trimToSize();
}
buildPath();
return true;
}
// 建立路径
private void buildPath() {
_path.clear();
Node node = _endNode;
_path.add(node);
while (node != _startNode) {
node = node.parent;
// _path.unshift(node);
_path.add(0, node);
}
}
public ArrayList</node><node> getPath() {
return _path;
}
private boolean isOpen(Node node) {
int len = _open.size();
for (int i = 0; i < len; i++) {
if (_open.get(i) == node) {
return true;
}
}
return false;
}
private boolean isClosed(Node node) {
int len = _closed.size();
for (int i = 0; i < len; i++) {
if (_closed.get(i) == node) {
return true;
}
}
return false;
}
private double manhattan(Node node) {
return Math.abs(node.x - _endNode.x) * _straightCost
+ Math.abs(node.y + _endNode.y) * _straightCost;
}
private double euclidian(Node node) {
float dx = node.x - _endNode.x;
float dy = node.y - _endNode.y;
return Math.sqrt(dx * dx + dy * dy) * _straightCost;
}
private double diagonal(Node node) {
float dx = Math.abs(node.x - _endNode.x);
float dy = Math.abs(node.y - _endNode.y);
float diag = Math.min(dx, dy);
float straight = dx + dy;
return _diagCost * diag + _straightCost * (straight - 2 * diag);
}
// public float getVisited() {
// return ArrayUtils.addAll(_closed, _open);
// }
}
AS3-Sokoban推箱子-寻路扩展
恩,是寻路扩展,而不是自动求解~自动求解那个实在过于复杂,不考虑呀么不考虑。
先看demo:
依然是前几天的Sokoban,只不过修改了下地图数据,另外加了个点击寻路功能。
在要去的点上点一下鼠标,就会自动移过去了。
下边来说下具体实现。