Tutorials, extensions, and source files for ActionScript, Flash, and other Adobe products.

 

senocular.com ActionScript Library

getRegisteredClass.as

Name: Object.getRegisteredClass() [MX] - gets class object associated with library ID
Author: senocular: www.senocular.com
Date: 1899-12-31T00:32:06.800
Documentation:
Object.getRegisteredClass: A function called directly from
the Object object, like Object.registerClass which will return
the class currently associated with the specified library
linker ID (which is used in Object.registerClass to set
the association).

Arguments:
- id: the library linkage id to check an associated class for

Returns:
- the class associated with the passed linkage id.  If no class is assigned, undefined
is returned.


- I used this in another proto but thought it could use to be on its own

Example:
myClass = function(){}
Object.registerClass("myLinkerID", myClass);
trace(myClass == Object.getRegisteredClass("myLinkerID")); // true

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Object.getRegisteredClass = function(id){
	if (!this._registeredClasses || !this._registeredClasses[id]) return undefined;
	return this._registeredClasses[id];
}
Object.$registerClass = Object.registerClass;
Object.addProperty("registerClass",function(){return function(id, class){
		if (!this._registeredClasses){
			this._registeredClasses = {};
			ASSetPropFlags(this,"$_registeredClasses",1);
		}
		this._registeredClasses[id] = class;
		this.$registerClass(id, class);
}},null);
ASSetPropFlags(Object,["$registerClass","getRegisteredClass"],1);