尽可能考虑禁用鼠标交互。
使用交互式对象(例如 MovieClip 或 Sprite 对象)时, Flash Player 执行本机代码以检测和处理鼠标交互。当屏幕上显示许多交互式对象时,特别是当它们重叠时,检测鼠标交互可能会占用大量 CPU 资源。避免此处理的一种简便方法是对不需要任何鼠标交互的对象禁用鼠标交互。以下代码说明了 mouseEnabled 和 mouseChildren 属性的用法:
// Disable any mouse interaction with this InteractiveObject
myInteractiveObject.mouseEnabled = false;
const MAX_NUM:int = 10;
// Create a container for the InteractiveObjects
var container:Sprite = new Sprite();
for ( var i:int = 0; i< MAX_NUM; i++ )
{
// Add InteractiveObject to the container
container.addChild( new Sprite() );
}
// Disable any mouse interaction on all the children
container.mouseChildren = false;
尽可能考虑禁用鼠标交互,这有助于您的应用程序使用较少的 CPU 处理,从而减少电池使用量。
Flash 平台技术的优化(五) 禁用鼠标交互
最新推荐文章于 2019-08-16 00:15:20 发布