?? memorymanage.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 + -