WEB开发网
开发学院图形图像Flash AS3开发时需要注意的几个点 阅读

AS3开发时需要注意的几个点

 2012-02-06 12:13:25 来源:本站整理   
核心提示:这些东东都不是很难,只是方法不常用或没注意到,AS3开发时需要注意的几个点,以后还会陆续添加,同时希望给位同学多提供一些Tips1、MouseEvent在某些时候要记得运行MouseEvent.updateAfterEvent();方法, …4、Flex中使用TitleWindow时如果要通过代码控制Cl

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

1、MouseEvent在某些时候要记得运行MouseEvent.updateAfterEvent();方法。

主要表现在拖动的时候。如果不执行该方法,会有延迟,比如拖动会有延迟。

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

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

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


  var date:Date = new Date();
  xmlLoader.load("xml.aspx?datestamp="
  +date.getMilliseconds());//xmlLoader是我自己的类,继承了Loader类。
  …
  4、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.

Tags:AS 开发 需要

编辑录入:coldstar [复制链接] [打 印]
赞助商链接