ASWing 源码简析
继承及子类关系:
=======================
AWSprite flash.display.Sprite
subClass Component
=======================
简析:
private var foregroundChild:DisplayObject; private var backgroundChild:DisplayObject;
基类AWSprite拥有 前景子元素 & 后景子元素
foregroundChild 在所有的元素之上.
层次结构:
foregroundChild
||
content
||
backgroundChild
=========================================
1. toString() 函数
给出了当前显示元素的层级关系, 从Stage到当前元素的层级链.
如图所示:
关于 root1 & ground_mc 是什么 稍后再了解
==========================================
2. 当设定usingBitmap的值为 true 时, 会将改父元素所有层中的显示元素都放置到content中;
当设定usingBitmap的值为 false时, 会将content中的所有显示都拿出来按顺序放置到父元素中.
==========================================
3. AWSprite 重写了 Sprite 的 addChild() , addChildAt(), removeChild(), removeChildAt(), getChildAt(), getChildByName(), getChildIndex(), setChildIndex(), swapChildren(), swapChildrenAt(),
numChildren()
主要用于判断当前是否选择了 usingBitmap 模式, 应该去c操作哪里的子元素.
其中以addChild重写得较多. 主要判断是否 存在前景元素、是否选择了usingBitmap模式的不同状态下增加子元素的
情况。
===========================================
4. 增加获取层数的方法:
public function getHighestIndexUnderForeground():int public function getLowestIndexAboveBackground():int
增加了将某个元素置顶和置底的方法:
public function bringToTop(child:DisplayObject):void public function bringToBottom(child:DisplayObject):void
和 设置 前景元素 背景元素的方法.
============================================
5. 新增了两个事件
ReleaseEvent.RELEASE ReleaseEvent.RELEASE_OUT_SIDE
当鼠标在当前元素及子元素上触发 MouseDown事件的时候, 此类会记录当前的事件的发起者, 同时给Stage注册一个MouseUp的监听器。
当鼠标在这之后触发MouseUp事, 程序会判断MouseUp的发起者是否是,MouseDown事件的发起者或者其父元素。
如果都不是,则说明Release这个事件是在离开MouseDown发起者有效范围的事件。
在MouseUp后,会发起ReleaseEvent.RELEASE,
如果是离开MouseDown发起者有效范围的则同时还会发起一个ReleaseEvent.RELEASE_OUT_SIDE事件。