as2 删除层级影片问题

关键要将main的引用赋值,防止被误删,导致加载swf空白

/**
	 * 删除所有对象  
	 * @param	standByRemoveMc      影片对象
	 * @param	removeSelf           是否删除自身
	 * @param   otherMc              main的引用
	 */
	public static function removeAllMcs(standByRemoveMc:MovieClip,removeSelf:Boolean,otherMc:Object){
		var m:MovieClip;
		for (var i in standByRemoveMc){
			m = standByRemoveMc[i];
			//trace(m +"   " + standByRemoveMc + "   " + standByRemoveMc._parent)
			//trace(m != standByRemoveMc)
			//trace(m != standByRemoveMc._parent)
			if (m != standByRemoveMc && m != standByRemoveMc._parent&&m!=otherMc){
				m.getDepth() < 0 ? m.swapDepths(m._parent.getNextHighestDepth()) : 0;
				m.removeMovieClip();
				m = null;
			}
		}
		
		if(removeSelf){
			standByRemoveMc.getDepth() < 0 ? standByRemoveMc.swapDepths(standByRemoveMc._parent.getNextHighestDepth()) : 0;
			standByRemoveMc.removeMovieClip();
			standByRemoveMc = null;
		}
	
	}

  

原文地址:https://www.cnblogs.com/dt1991/p/10188945.html