Created
November 24, 2011 13:18
-
-
Save vrobel/1391327 to your computer and use it in GitHub Desktop.
LibraryManager.removeGroupsContaining
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Removes all groups containing given string | |
* @param str: Search phrase for groupIds | |
*/ | |
public static function removeGroupsContaining(str:String):void{ | |
var toBeRemoved:Array = []; | |
for (var groupId:String in LibraryManager._groupMap) { | |
if(groupId.indexOf(str) != -1) { | |
//get group | |
var loadsNames:Dictionary = LibraryManager._groupMap[groupId]; | |
//iterate over the group | |
for (var process:* in loadsNames) { | |
//for GroupLoad remove all processes inside | |
if(process is GroupLoad ){ | |
for each (var process1:Process in (process as GroupLoad).loads) { | |
if(process1 is SwfLoad){ | |
LibraryManager.removeSwfLoad(process1 as SwfLoad, groupId); | |
delete loadsNames[process]; | |
(process as GroupLoad).removeLoad(process1); | |
(process1 as SwfLoad).destroy(); | |
(process1 as SwfLoad).loader.unloadAndStop(false); | |
return; | |
} | |
} | |
//for single SwfLoad just remove them | |
}else if(process is SwfLoad){ | |
LibraryManager.removeSwfLoad(process as SwfLoad, groupId); | |
delete loadsNames[process]; | |
(process as SwfLoad).destroy(); | |
(process as SwfLoad).loader.unloadAndStop(false); | |
return; | |
} | |
} | |
} | |
toBeRemoved.push(groupId); | |
} | |
for (var i:int = 0; i < toBeRemoved.length; i++) { | |
removeGroup(toBeRemoved[i]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment