当前位置:软件学习 > Flash >>

AS3的通用工具类库 GhostCat

GhostCatTools已经发布,使用Flex Spark框架以及AIR和部分GhostCat功能制作。 包含大量开发常用的功能。
AS3的通用工具类库 GhostCat
下载地址:http://ghostcat.googlecode.com/svn/trunk/GhostCatTools/GhostCatTools.exe

AS3的通用工具类库 GhostCat
GhostCat是一个功能非常丰富的开源工具库,(同时也包含有一套完整的UI组件,但它只是类库的一个衍生品。)
它基本可以涵盖你可能遇到大部分问题。
使用UI将会增加50K左右的体积,使用非UI显示对象会增加20K以上的体积,而非显示类可以非常小。

GhostCat采用BSD协议可以自由地应用于商业及非商业应用中。如果您使用了GhostCat,甚至用于实际项目中,希望能通过邮件给予回馈。

http://code.google.com/p/ghostcat/

实际应用项目

升职记 CeoDream
php" rel="nofollow">http://app.pengyou.qq.com/appframe.html?appid=608&height=950&frame=http%3A%2F%2Fceo.qzoneapp.com%2Findex.php ps.renren.com/ceodream" rel="nofollow">http://apps.renren.com/ceodream
http://apps.facebook.com/ceodream

GhostCat is a feature-rich open source tools for libraries, (which also contains a complete set of UI components, but it is only a class library derivatives.)
It basically can cover most of the problems you may encounter.
Using the UI will increase the size of 50K or so, use of non-UI display object will increase more than 20K in size, rather than display type can be very small.

GhostCat using BSD agreement may be freely used in commercial and non-commercial applications. If you use a GhostCat, even for the actual project, we hope to give feedback through e-mail.

The practical application of project

renren.com: ceo dream
http://apps.renren.com/ceodream?origin=103&_vip_flag=32

@author flashyiyi
blog:http://uh.actionscript3.cn/space.php?uid=12147

参考
http://ghostcat.googlecode.com/svn/trunk/GhostCat/asdoc-output.chm

SWC下载
http://ghostcat.googlecode.com/svn/trunk/GhostCat/bin/GhostCat.swc

SVN工具
http://tortoisesvn.net/downloads.html

教程可查看wiki

示例(打不开就用IE):
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/AStarExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/BindingExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/CollisionExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/ControlRectExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/GIFExample.html
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/GXMLExample2.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/GXMLExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/IFrameExample.html
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/IMEExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/LangageExample.html
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/LightExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/Paper3DExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/RightClickExample.html
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/SkewExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/SmoothCurveExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/SWFDecoderExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/TestExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/Tile45Example.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/TileExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/TweenExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/SortExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/EllipseLayoutExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/PixelExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/TableExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/StringTweenExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/BitmapScreenExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/SoundExample.html
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/TransitionExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/FrameRateExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/WalkExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/MazeExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/BombExample.swf

几个简单的UI示例
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/UIBoxExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/UIBuilderExampler.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/UIComboBoxExample.swf
http://ghostcat.googlecode.com/svn/trunk/example/bin-release/UIScrollExample.swf


GhostCat原 名ASGameUI,初期设计只是想做一个轻量化的UI组件库。FLEX暂且不提,就算AsWing实际上都未能实现和Sprite的完美结合,而且体积 依然很抱歉。因此,很多开发者最终被迫选择了自行开发。然而,他们开发的东西要不功能不够,不要是针对性工具,缺乏通用性,因此并无法补齐这个空缺。
ASGameUI来源于一个“逻辑注入”的设想,牺牲了布局的便利性,并充分利用FLASH IDE为自身服务,使得它在符合面向对象的编程方式的同时,亦实现了和原始时间线开发类似的自由度和便利性,从而可以在纯代码环境下直接套用原本动画网站 丰富的表现方式,达到两种互斥方式的结合。从而,使得在开发丰富表现的UI时,开发成本大幅度降低。
值得一提的是,虽然GhostCat在底层引入了与UI无关的大量内容,在使用UI时体积依然只有50K出头(不使用UI会很低)。这主要来源于松散的类库设计。你可以将大量内容引用,并在项目中充分使用其功能,也可以仅仅引用一个功能点,你并不会因为引入了一个功能而使得SWF体积大幅度上升。
GhostCat的UI充分考虑了其表现。除了亲和MovieClip之外,它同时在组件内部自带了缓动和动画效果。这是目前其他类库所没有的。而且,和一些自写类库相比,GhostCat在控制体积的同时,亦提供了布局,List,ItemRender等高级特性,使得它在基本功能上同样不亚于ASWing,FLEX等组件,仅仅是效率和便利程度上不及。

GhostCat之所以改名,是因为这个类库目前已经远远超出了UI的概念。它利用自己的基层类库进行发散,诞生了许多有用而独特的功能,诸如:

提供了MovieClip的扩展:
你可以用同一种方式操作矢量动画,位图动画,以及代码动画并可将动画进行拼接处理。动画自带倒放,帧速控制,播放队列功能,并可将矢量动画转换为位图动画播放。

一个奇特的动态内容显示模块:
可以很简单的使用(你可以假想它只是一个超大的重复内容图形),由它自动进行重复对象的创建,移动,删除,完美处理缩放和移动。而且,它甚至是List实 现的基础!仅仅是重写了几个方法,它便可以立即实现45度角的游戏地图效果。你也可以把它仅仅作为一个逻辑类,并利用事件,实现你想要的任何功能。

一个非常完善的XML反序列化器:
你可以用它表述任何种类的类(可以包含构造函数参数列表),并且模仿FLEX实现了事件自动监听,属性外链等功能。可以是多层显示对象的序列化,也可以是 一组包含复杂类的数据。扩展它也很简单。你只需要理解并重写它的3个方法,而如果仅仅是想进行属性名称的转义,只需要设置一个属性即可,而这也是自定义解 析器最常见的需求。

一个通用型队列系统:
它不仅仅用来进行资源的排队加载,而且可以排队任何东西!函数,声音,弹窗,以及判断,转向,循环。某种程度上,它甚至像是一个脚本引擎。而使用和扩展亦 非常简单。使用它,new,然后commit()即可,要扩展它,你只需要实现一个普通的命令模式,有效代码可以只有几行。作为例子,我已经提供了一个简 单的任务系统,在这种需求里,命令模式的优势被表现得淋漓尽致。这也是一个处理AS3没有多线程时的代替方案。

一个简便的位图引擎:
是的,虽然同样是addChild,但通过这种方式加上去的东西,就是用自带的优化渲染方式实现的。在大量物品移动时,它可以比默认渲染方式获得更好的性 能。并且,它还可以即时地在多种渲染模式内切换,使用风险较低。位图引擎亦实现了基本的鼠标事件模拟功能。从这个地方开始扩展,提供了一个使用很简单的位 图特效类,只需要一个行代码和简单的设置便可让对象拥有平滑残影和扩散特效。再配合物理类,便可以形成一个完整的粒子引擎。

GhostCat的功能远不止上面所说,事实上,大部分的通用功能它都已经在内部获得了实现(诸如Tween),这些就不就再提了。仅仅列出一些特殊功能。
-判断矢量边缘实现不规则物品碰撞检测(非位图)
-高效位图碰撞及重叠矢量检测
-A星,深/广度,2D/3D/路点,寻路方式统一处理。
-二次贝尔法曲线,按长度切割和计算法线,光滑曲线拟合(过点或者不过点)
-SWF解析器,从ByteArray中播放声音,直接控制AVM1的动画类容。
-丰富的文本缓动,部分文字Filter,渐变色文字,字符差异对比,ANSI转码,URL解码,中文数字,拼音码,这是一个单独的底层包
-完全由FLASH实现的拼音输入法,需要加载200K的词库,光标跟随并可词语输入(感觉和智能ABC差不多)
-缩略图,倒影,梯形变换,马赛克,各种特效,火焰什么的
-完整功能的自定制过渡,不仅能用,也能创造。如果不会用,可以使用Creater中的模板
-粒子,物理,景深
-像QQ那样截屏!
-流方式读取文本和图片。HTML可以,FLASH也可以
-和FXG类似的道理,用对象保存绘制操作,简化绘制过程
-多种拖拽工具,变形工具,编辑形状工具。单个拖动点也可单独使用。
-单文件自加载
-右键,双击,三击,键盘管理,鼠标手势
-影子生成器。FLASH也是可以模拟出效果不错的光影的。影子可以折墙壁
-防客户端修改解决方案(内存修改,加速)
-切割图形,同时支持矢量,位图,而且,你可以按45度角来切!
-颜色模式转换
-去背景,魔法棒
-图文混排的简单实现。也可以显示Table表格
-滤镜代理:修改了滤镜的属性便能立即生效,你可以直接对它Tween!当然,水波放大镜,对比度饱和度顺便也提供了。
-常用的JS扩展:IFrame,便捷的提供接口给外部JS,调用浏览器音乐播放器播放MID,以及一些常用的防刷新,防鼠标滚轮干扰。当然,deeplink是不可少的。
-扇形,圆环,虚线
-四则运算(字符串分析)
FP10限定
-Beep音乐,变速播放

也许在使用上,GhostCat还是需要一些成本(至少你需要知道各个功能都在哪个位置),但是这是值得的,一些问题可能你现在不会遇到,将来也可能会遇到。这是一件一劳永逸的事情。同时,我也希望GhostCat也能给你一些启发,让你去做一些以前认为无法做到或者过于麻烦而不去做的事,如此,提高FLASH产品的质量,从而促进行业发展,使所有人受益。

补充:flash教程,As3.0 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,