Spicelib Reflect is a reflection library to reflect on classes, methods and properties. The lib was created to improve the workflow required to parse the XML output from Flash’s describeType funcionality. The lib builds on top of the output generated by describeType and offers a convenient central cache so that XML parsing occurs only once for each class. There is a central repository to register Converter instances for any number of target types.

It’s also possible to use methods to reflectively set properties and invoke methods of instances while using the registered converters to automatically convert method parameters and property values if their type does not match the required type. A developer also has the option to register custom classes to represent metadata tags to offer a type-safe way to reflect on metadata tags and its attributes.


// Reflecting the flash.geo.Point class
var ci:ClassInfo = ClassInfo.forClass(Point);
var p:Property = ci.getProperty("x");
trace("type:     " + p.type.name); // Number
trace("readable: " + p.readable); // true
trace("writable: " + p.writable); // true

var point:Point = new Point(7, 5);
p.setValue(point, 12);
trace(point.x); // output: 12

var m:Method = ci.getMethod("add");
var params:Array = m.parameters;
trace("param count: " + params.length);
var param:Parameter = params[0] as Parameter;
trace("param type: " + param.type.name);
trace("param required: " + param.required);
trace("return type: " + m.returnType.name);

var result:Point = m.invoke(point, [new Point(3, 3)]);
trace(result.x); // output: 10
Debug . URL.