Flex - Grabbing all instances of SystemManagers

Tags: , ,

There are some cases when you'll want to be aware of all SystemManagers in your flex application (like when you load child applications).

This can be done fairly easily with the following code

import mx.managers.SystemManagerGlobals;
//top level list of system managers
			var systemManagers:Array = SystemManagerGlobals.topLevelSystemManagers;
			//length for efficiency
			var lng:int = systemManagers.length;
			for(var i:int = 0; i < lng; i ++){
                                       //type with a wildcard because we may encounter systemManager or windowed system manager
					var sm:* = systemManagers[i];
					//logic
				}
	  		}

This is the same logic that adobe uses to access these within the framework