- package org.geom
- {
- public class ObjBase
- {
- public function ObjBase() {}
- //清除对象中特定类型对象
- public static function cleanObjByType(type:*, container:*) {
- //对象为空返回
- if (container.numChildren == 0) { return; }
- //清除布局内容
- var clearObjBox:Array=[]
- for (var j = 0; j < container.numChildren;j++ ) {
- var item:*= container.getChildAt(j)
- if (item is type==true)
- {
- clearObjBox.push(item)
- }
- }
- if (clearObjBox.length == 0) { return; }
- for (var k = 0; k < clearObjBox.length;k++ ) {
- container.removeChild(clearObjBox[k])
- }
- }
- //从父容器中清除
- public static function cleanObj(obj:*) {
- if (obj == null) { return; }
- if (obj.parent == null) { return; }
- obj.parent.removeChild(obj)
- }
- //清除对象所有子对象
- public static function cleanAll(container:*) {
- //对象为空返回
- if (container.numChildren == 0) { return null; }
- var clearObjBox:Array = []
- for (var j = 0; j < container.numChildren;j++ ) {
- var item:*=container.getChildAt(j)
- clearObjBox.push(item)
- }
- if (clearObjBox.length == 0) { return; }
- for (var k = 0; k < clearObjBox.length;k++ ) {
- container.removeChild(clearObjBox[k])
- }
- }
- //获取某类对象集合
- public static function getObjs(type:*, container:*):Array {
- //对象为空返回
- if (container.numChildren == 0) { return null; }
- //清除布局内容
- var ObjBox:Array = []
- for (var j = 0; j < container.numChildren;j++ ) {
- var item:*= container.getChildAt(j)
- if (item is type ==true)
- {
- ObjBox.push(item)
- }
- }
- if (ObjBox.length == 0) { return null }
- return ObjBox
- }
- //清除除某类对象之外的所有对象
- public static function cleanAllBesideType(type:*,container:*) {
- //对象为空返回
- if (container.numChildren == 0) { return null; }
- var clearObjBox:Array = []
- for (var j = 0; j < container.numChildren;j++ ) {
- var item:*= container.getChildAt(j)
- if (item is type==false)clearObjBox.push(item)
- }
- if (clearObjBox.length == 0) { return; }
- for (var k = 0; k < clearObjBox.length;k++ ) {
- container.removeChild(clearObjBox[k])
- }
- }
- //除指定对象可见外其他对象不可见
- public static function setObjShow(container:*) {
- //对象为空返回
- if (container == null) { return null; }
- //对象为空返回
- if (container.numChildren == 0) { return null; }
- for (var j = 0; j < container.numChildren;j++ ) {
- var item:*= container.getChildAt(j)
- item.visible=true
- }
- }
- //除指定对象不可见外其他对象可见
- public static function setObjHide(container:*) {
- //对象为空返回
- if (container == null) { return null; }
- //对象为空返回
- if (container.numChildren == 0) { return null; }
- for (var j = 0; j < container.numChildren;j++ ) {
- var item:*= container.getChildAt(j)
- item.visible=false
- }
- }
- }
- }
ObjBase类
最新推荐文章于 2021-02-27 21:23:19 发布