I Love China

技术·人生

技术服务生活
繁體

Archive for 4月, 2008

[APMXE5]让APMXE5支持中文路径

星期一, 4月 28th, 2008

在httpd.conf里加上AddType application/x-httpd-php .php
AddType image/x-icon .ico
然后把php5\php5ts.dll拷贝到apache\bin\目录下,重启服务器即可

[ajax]FireFox和IE下使用ajax的一些小问题总结

星期六, 4月 26th, 2008

1、FireFox下使用xmlHttpRequest的send方法是必须指定参数。即.send();是无效的,如果没有参数要使用.send(null);.
2、FireFox下处理DOM时把空白也当作是一个节点。因此为了避免出现一些意想不到的问题,要尽量不要使用空白(包括换行、空格等等)。
3、使用createElement创建节点时,IE下可以用document.createElement(”<tr>”);但是FireFox下只能用document.createElement(”tr”);
4、添加子节点,IE可以用add,但是FireFox下不可以。FireFox下只能用appendChild.
5、如果IE下往table节点里添加tr达不到预期效果,常常是因为没有添加tbody节点。
6、IE下使用javascript设定td的colspan无效是因为大小写的问题,必须使用colSpan。
7、FireFox下输出从服务器端返回XML时注意开头不能有空白(包括换行、空格等),否则会有解析错误。
8、使用xmlHTTPRequest实现分页效果时,每次处理完一次请求要把xmlHTTPRequest对象消掉,下次使用时再重新构建。
9、通过代码指定style的值时,必须加上单位,比如设定style.left=50;这样虽然在IE下有效,但是在FireFox下是无效的,必须写成style.left = “50px”;

[转]构建Flex程序时容易犯的10个错误

星期五, 4月 25th, 2008

原文地址Top 10 Mistakes when building Flex Applications

  1. Using an RIA framework to build Web 1.0 applications (aka. New technology same old stuff).
  2. 使用RIA框架构造Web 1.0的应用程序。

    One of the largest challenges when moving from Web 1.0 applications to the RIA’s development paradigm is learning to think differently. Flex gives developers an advanced component library that allows for doing things that simply weren’t possible only a few years ago. Often, the power of Flex is missed, and the framework is used to implement more traditional Web 1.0 applications.

    从Web 1.0应用程序转到RIA程序开发上时一个很有挑战的事情是学会以不同的方式思考。Flex为开发者提供了一个高级组件库,使用这些组件就可以很简便的做一些前些年都不可能的事情。但是,常常会忘了Flex的这个强大功能,而仅仅使用框架开发传统的Web 1.0应用程序。

    Building Web 2.0 applications is more than partial page refresh and rounded corners. For example, Flex developers should be using vectors to provide users a visual understanding of data, and advanced controls for a rich application flow. Stephan Janssen discusses this struggle recently with InfoQ.com:
    As a Java developer, learning Object Oriented ActionScript and the UI markup language is really a walk in the park. The challenge however for (Java) developers is that we’re not designers, and with RIA technologies these two skills are very much needed.

    构建Web 2.0应用程序不仅仅是实现页面的局部刷新和圆角。比如,Flex开发者应该使用图形把数据以可见、易懂的方式展示给用户,并提供对应用程序流程控制的高级操作。Stephan Janssen 这样说:对于一个Java开发者,学习面向对象的ActionScript和UI标记语言是很简单的事情。但是对于Java开发者来说,困难在于我们不是设计师,但是对于RIA技术来说这两种技能都需要。

  3. Breaking standard browser experiences.
  4. 忽略了标准的浏览器体验。

    While Flex does provide an excellent platform for improving the user experience, it still important to maintain familiarity of things like the back button, book marking, and auto complete.

    尽管Flex提供了一个改善用户体验的优秀平台,但是有些很重要的功能不应该忽略,比如后退按钮,书签,以及自动填充。

    Flex 3 includes new Deep Linking features for back button support and book marketing. You can learn more at labs.adobe.com. There are number of components out there for implementing auto-complete. From the Adobe Exchange, you can use the AutoComplete Input component.

    Flex 3 包含了新的深度链接功能以支持后退按钮和书签。更多知识请访问labs.adobe.com。另外还有一些组件实现了自动填充。从Adobe Exchange 你可以找到自动填充的输入组件。

  5. Slowing the application down with the use of too many containers.
  6. 过多使用容器导致应用程序运行缓慢。

    Flash Player uses a hieratical display object graph, similar to the HTML Document Object Model (DOM). The deeper containers are nested the longer the rendering takes. Adobe’s Flex Developer Center has an article that covers best practices related to Flex performance, including the use of containers in detail:
    The biggest Flex performance danger is yielding to the temptation to use containers randomly. Deeply nesting too many containers hinders the performance of your application. This is the number one performance danger that Flex developers succumb to—and luckily it is 100 percent avoidable.

    Flash Player 使用继承的结构显示对象图形,就像HTML文档对象模型(DOM)。容器嵌套的越深,渲染需要的时间越久。Adobe的开发者中心有一篇描述Flex性能的文章,其中也包含了使用容器的细节:深度嵌套很多容器会降低你应用程序的性能。这是Flex开发者最可能出错的地方,幸运的是我们100%可以避免它。

  7. Slowing the application down by using XML for data transfer over optimized protocols.
  8. 使用XML传输数据降低应用程序的速度。

    Flex offers developers a number of options for data transfer between the Flex client application and the server, including AMF3, XML, SOAP, and straight HTTP requests. Ward demonstrates the use of these technologies and performance benchmarks in his Census application.

    Flex为开发者提供了几种Flex客户端和服务器之间数据传输的选择,包括AMF3,XML,SOAP,以及直接的HTTP请求。Ward在他的Census中演示了使用这几种技术的性能表现。

    BlazeDS should be considered for Greenfield projects using Java on the backend. BlazeDS is Adobe’s recently open sourced Data Services product that uses the AMF3 protocol. AMF is a binary transfer protocol that is easy to integrate with Java, and offer significant performance benefits over XML. There are open source implementations of AMF for every major backend technology.

    在使用Java做后台的工程里可以考虑使用BlazeDS。BlazeDS是Adobe最近开源的数据服务产品,它使用AMF3协议。AMF是二进制传输协议,用Java结合起来非常容易,并且拥有XML的很多重要性能特征。当前已经有针对每个主流后台技术的AMF的开源实现。

    If BlazeDS is not an option, Hessian could be an option. Hessian offers ActionScript/Flex support for their binary web services protocol.

    如果不用BlazeDS,还可以使用Hessian。Hessian为他们的二进制Web服务协议提供了ActionScript/Flex支持。

  9. Trying to hire Flex developers.
  10. 尝试雇佣Flex开发人员。

    Experienced Flex developers are very hard to find right now. Flex is at the point in the adoption curve which Java was at in the late nineties. The demand for Flex developers is exceeding the supply. This makes finding experienced Flex developers difficult. This, however, creates a huge opportunity for Java developers to expand their skill sets and work with a fun emerging technology. Many companies looking for Flex developers have great success training Java or other web application developers for only a few weeks on Flex. Flex’s language and APIs are easily learnable by developers who are familiar with Web and GUI programming.

    现在很难找到有经验的Flex开发人员。现在Flex的情况跟上世纪90年代时Java的情况差不多。Flex开发人员供不应求。这造成了寻找有经验的Flex开发人员比较困难。不过,这也给了Java开发者一个扩展他们技能、使用一种有趣技术的巨大机会。很多公司仅仅使用几个星期就把Java或者其他Web应用程序开发人员培训成立Flex开发人员。对于熟悉Web和GUI编程的开发者来说,学习Flex的语言和API是很容易的。

  11. Over use of animations
  12. 过度使用动画。

    Using Flash as the runtime enables developers to easily add animations and effects. However, developers should make sure that the animations have meaning and provide context. Otherwise, they will annoy users. The timing of animations is also important. Interaction designers can help make recommendations on when animations should and should not be used. Interaction designers can also recommend the best type of animations, the duration, and the best easing function.

    在运行期使用Flash使得开发者很轻松的添加动画和特效。但是,开发者应该确定使用的动画是有意义。有内容的。否则,他们会惹恼用户。动画的时间也很重要。交互设计师可以帮助决定何时使用动画,何时不应该使用。交互设计师同样可以推荐最佳的动画类型、时间长度以及最佳的过度效果。

    There is good a post on the use of animations at laair.org:
    Most animations are simply TOO LONG. They are long, and slow, and boring, and excessive. Tone it down. If there is one thing I have found, its that I hate waiting for stupid animations to finish so I can do something else.

    laair.org上有一篇很好的关于使用动画的文章:大多数动画都太长。又长、又慢,惹人烦。如果说我从中发现了什么的话,那就是我痛恨要一直等到那愚蠢的动画结束后才能进行其他操作。

    Don’t get me wrong I am not bashing animations. I am simply bashing animations that are simply too long or too extravagant for their purpose. Every animation can be broken down to having a purpose. Figure out the purpose of your animation and apply accordingly.

    不要误会我的意思,我并不是在抨击动画本身。我只是批评那些太长或太过分的动画。每个动画都是有目的性的。明确你使用动画的目的能帮助你正确的应用动画。

  13. Not setting up an enterprise ecosystem.
  14. 没有建立一个企业级的生态系统。

    As with other software projects, it is important to setup an enterprise ecosystem for your Flex applications.

    跟其它软件工程一样,为你的Flex应用程序建立企业生态系统很重要。

    Test Driven Development (TDD) is a staple of most any enterprise project in this day-and-age. For Flex, the FlexUnit framework is available for coding unit tests. On Adobe’s Developer Connection, Neil Webb discusses TDD for Flex developers and using FlexUnit. In addition, Flexcover is available for code coverage reporting.

    当今大多数企业工程中主要用的是TDD。对于Flex,FlexUnit框架能够用来测试代码单元。在Adobe的开发者联盟上,Neil Webb为Flex开发者介绍了TDD以及使用FlexUnit。另外,也可以使用Flexcover。

    Continuous Integration (CI) is a proven practice for building cohesive applications when multiple developers are contributing. Similar to Java applications, both Ant and Maven plug-ins are available for CI builds of your Flex applications.

  15. Not using the entire framework.
  16. 没有使用整个框架。

    There are a number of optional features available in Adobe Flex that you should consider using in your applications. For example, Runtime Shared Libraries (RSL) is available for reducing the size of your applications:
    You can shrink the size of your application’s resulting SWF file by externalizing shared assets into standalone files that you can separately download and cache on the client. Multiple Flex applications can load these shared assets at runtime, but each client need only to download them once. These shared files are called Runtime Shared Libraries.

    Flex中提供了一些功能你应该考虑用到你的程序中。比如,运行时共享库(RSL)能够减小程序的文件大小:
    把共享资源放到单独的文件中,然后分开下载它们并缓存在客户端,使用时再连接到程序中,这样就能减小程序最终生成的SWF文件的大小。多个Flex程序都可以在运行时加载这些共享资源,而用户只需要下载一次就可以了。这些共享的文件被称为运行时共享库。

    Another under used feature of the framework is the built in accessibility features. You can read more about the accessibility features of Flex in Adobe’s livedocs. In addition to built in accessibility, the framework provides built in features for localization. For the latest Flex 3 framework features, checkout Adobe’s Getting Started introduction page.

    另外一个可能被忽略的功能是内置的辅助功能。你可以阅读Adobe的在线文档获取详细信息。除了内置的辅助功能,本框架还提供了本地化的功能。更多功能请查看Adobe的介绍页面。

  17. Slowing the DataGrid down with complex renderers.
  18. 使用复杂的渲染降低了DataGrid的效率

    The out-of-the-box itemRenderer for the DataGrid is very optimized. Mistake #3 discussed the performance impacts of deeply nested containers. One of the places in Flex where containers can easily get deeply nested is in the DataGrid’s item renderers. The number of item renderers which are rendered by the DataGrid is the number of visible rows times the number of visible columns. Custom DataGrid and List item renderers should be very optimized. When complex layout logic is needed in an item renderer, it is best to use UIComponent (or other more low-level classes) and position the contents for that cell manually.

    DataGrid的itemRender非常实用。本文的第3条错误描述了深度嵌套影响性能。Flex中能够轻松嵌套的就是DataGrid的item renderer。DataGrid需要渲染的子项个数 = 可见的行数*可见的列数。自定义的DataGrid和List的item renderer应该好好优化。如果需要在一个item renderer中使用复杂的排列逻辑,最好是使用UIComponent(或其他低层次的类)并手动设置单元格的内容。

  19. Not Preparing for Offline Applications.
  20. 没有准备脱机使用的程序。

    The traditional model for RIAs is in the browser. However technologies like Adobe AIR and Google Gears is allowing those applications to run offline. By not preparing for a potential offline architecture when users demand it, changing your applications to support offline features may be very difficult. Typically, in web applications business logic lives on the server. In offline RIAs, business logic must transition to the client. This makes it nessecary to architect ahead of time where certain business logic will need to live in order for applications to work both offline and online.

    RIA的传统模式是浏览器。但是像Adobe AIR和Google Gears这样的技术允许应用程序脱机工作。如果没有事先设计好脱机部分的结构而用户又需要它,这时候再改变你的程序来支持脱机工作的功能可能会非常困难。通常,事务逻辑由服务器保持。但在脱机工作的RIA程序中,事务逻辑必须转移到客户端。所以要事先考虑到事务逻辑应该保存在哪里才能让应用程序既能脱机工作也能联机操作。

[jsfl]调整场景顺序

星期三, 4月 23rd, 2008

以前以为jsfl不能控制FLA的场景,今天需要用到这个功能,然后用批量导出,又仔细看了下帮助,发现是可以的。虽然timeline指向当前时间轴可以是当前场景、正在编辑的当前元件或当前屏幕。但是当打开FLA时,它指的就是当前场景,使用timelines.length就是场景的个数,这样,我们就可以把所有fla文件的最后一个场景调整成第一个场景,然后导出
JSFL Code

var doc = fl.openDocument(p_fileURI);
// 将最后一个场景移到最前面
var sceneNum = doc.timelines.length;
doc.reorderScene(sceneNum - 1,0);
// 不保存
//doc.save();
doc.publish();

[wordpress]升级wordpress到2.5的小波折

星期五, 4月 11th, 2008

到wordpress官网上看到已经到了2.5了,我想着升级一下吧。看到官方网站上写的zip格式的大小是1.2M,我用QQ超级旋风下载后发现居然只有622.52KB,当时也没太在意,解压后就上传了,然后从后台更新数据库,从前台一看,模板居然不正常了,有好几个语法错误。并且以前上传的附件,居然给我当作文章显示出来!打开readme.html一看,里面写的版本居然是2.0的。Oh My God!也就是说我从2.1版升级到了2.0版!!-_-!
缓存问题?我重新改了下下载链接,改成http://wordpress.org/latest.zip?dsfsdf,下载后发现文件大小是1.30M,打开readme.html看,写的是version2.5,这个才是对的。唉!真郁闷啊。
以后不用QQ超级旋风下载了。

[wordpress]一个繁简转换的小程序

星期三, 4月 9th, 2008

声明:这是从网上看到的。
一个网页中繁简转换的小程序。具体效果可以点本站页面右上角左右的【繁体/简体】转换
使用方法
1、下载文件tw_cn.zip,并解压出来。

2、打开tw_cn.js,根据代码中的注释修改一下。
3、上传文件tw_cn.js到网站根目录;

4、修改主题,在你想要显示简繁转换按钮的地方加上代码:

<a id=”translateLink”>繁體</a>

5、然后在footer里加上如下代码:

JAVASCRIPT Code

<script type="text/javascript"
src="http://yourdomainname.com/tw_cn.js" mce_src="http://yourdomainname.com/tw_cn.js"></script>
<script type="text/javascript">
var defaultEncoding = 0; //默认是否繁体,0-简体,1-繁体
var translateDelay = 0; //延迟时间,若不在前, 要设定延迟翻译时间, 如100表示100ms,默认为0
var cookieDomain = "http://yourdomainname.com"//Cookie地址, 一定要设定, 通常为你的网址
var msgToTraditionalChinese = "繁體"//默认切换为繁体时显示的中文字符
var msgToSimplifiedChinese = "简体"//默认切换为简体时显示的中文字符
var translateButtonId = "translateLink"//默认互换id
translateInitilization();
</script>