⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memorymanage.as

📁 用Flex开发的RSS通用阅读器
💻 AS
字号:
package cn.iservice.util
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.net.LocalConnection;
	
	import mx.collections.ArrayCollection;
	import mx.controls.List;
	
	public class MemoryManage
	{
		public function MemoryManage()
		{
		}
		/**
		 * 强制垃圾回收
		 */ 
		public static function  gc():void
		{
			trace("Clear memory start...");
			try
			{
				new LocalConnection().connect("foo");
				new LocalConnection().connect("foo");
			}
			catch(e:Error)
			{
				
			}
		}
		public static function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void
		{
			//super.removeEventListener(type,listener,useCapture);
			//delete eventList[type];
		}
		/**
		 * 移除所有的监听
		 */ 
		public static function removeAllListener(eventList:List):void
		{
			for(var prop:String in eventList)
			{
				removeEventListener(prop,eventList[prop]);
			}
		}
		/**
		 * 移除所有的子对象
		 */ 
		public static function removeAllChild(numChildren:Array):void
		{
			while(numChildren.length>0){}
				//removeChildAt(0);
		}
		public static function removeAllChildByArray(parent:DisplayObjectContainer,childrenArray:Array):void{
				var dataArrayCollection:ArrayCollection = new ArrayCollection(childrenArray); 	
	            for(var i:int=0;i<dataArrayCollection.length;i++){
	            	//parent.removeChild(dataArrayCollection.getItemAt(i));
	            	trace(dataArrayCollection.getItemAt(i).toString());
	            }
		}
		/**
		 *  移除对象开始
		 */ 
		public static function removeSelf(eventList:List,numChildren:Array):void
		{
			removeAllChild(numChildren);
			removeAllListener(eventList);
//			if(parent)
//				parent.removeChild(this);
			/**回收不用的资源*/
			gc();
		}
		/**
		 * 移除对象打印信息。
		 */ 
		public static function removeStart():void{
			trace("Remove listener start...");
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -