十一 272008
 

这些东东都不是很难,只是方法不常用到或没注意到:)以后还有陆续有添加。同时也希望给位同学多多提供一些Tips

1、MouseEvent在某些时候要记得运行MouseEvent.updateAfterEvent();方法。主要表现在拖动的时候。

如果不执行该方法,会有延迟,比如拖动会有延迟。

2、某些时候要记得stopImmediatePropagation(参考:做个笔记Event的stopImmediatePropagation和stopPropagation方法

主要表现在单击某元素的时候,不希望这个click操作到达下一层。因为stopImmediatePropagation立即进行了事件冒泡。防止对事件流中当前节点中和所有后续节点中的事件侦听器进行处理。

Example:

3、同AJAX一样,多次请求一个动态页面请加个时间戳,防止缓存。

...
var date:Date = new Date();
xmlLoader.load("xml.aspx?datestamp="
	+date.getMilliseconds());//xmlLoader是我自己的类,继承了Loader类。
...

4、(感谢望月狼的留言)

mouseEnabled  = false

?.tabEnabled = false

?.mouseChildren = false

?.tabChildren = false

把DisplayObjectContainer所继承的这四个属性都设掉,可降低cpu运算率
5、Flex中使用TitleWindow时如果要通过代码控制CloseButton按钮记得使用invalidateDisplayList();方法

(参考:使用代码控制TitleWindow的showCloseButton的奇怪问题)

它其实实现的是mx.core.UIComponent的updateDisplayList()方法。但是不可能直接使用该方法。

Help中是这么写的。

Draws the object and/or sizes and positions its children. This is an advanced method that you might override when creating a subclass of UIComponent.

You do not call this method directly. Flex calls the updateDisplayList() method when the component is added to a container using the addChild() method, and when the component’s invalidateDisplayList() method is called.

If the component has no children, this method is where you would do programmatic drawing using methods on the component’s Graphics object such as graphics.drawRect().

If the component has children, this method is where you would call the move() and setActualSize() methods on its children.

Components may do programmatic drawing even if they have children. In doing either, you should use the component’s unscaledWidth and unscaledHeight as its bounds.

It is important to use unscaledWidth and unscaledHeight instead of the width and height properties.

  6 Responses to “ActionScript 3开发的几个注意点”

  1. 博客换主题啦,挺漂亮

  2. @Mojojo:有人说俺的博客看上去太压抑了。-_-!呵呵,这个的确看得清爽点:)

  3. 换主题了,焕然一新。

  4. @Y.Boy
    呵呵,其实是换回去:)
    之前就是用这个主题的。哈哈。。。

  5. 不错,我给补一条
    mouseEnabled = false
    ?.tabEnabled = false
    ?.mouseChildren = false
    ?.tabChildren = false
    把DisplayObjectContainer所继承的这四个属性都设掉,可降低cpu运算率

  6. @望月狼:多谢多谢!!!

Sorry, the comment form is closed at this time.