宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应
您当前的位置: > 博客2 > AS2与AS3技术

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

2016-10-13 00:16:48 点击量:4 标签: 收藏本文

  这些东东都不是很难,只是方法不常用或没注意到,以后还会陆续添加,同时希望给位同学多提供一些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.

ABOUT US
宜昌农人网络科技有限公司

我们是一家提供综合软件外包与弱电工程服务的技术公司。

业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。

公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室