Apr 26
I just managed to release a new version of the Prana Framework. The new release contains an AS3 Reflection API and some general updates.
Reflection API
A quick example of the Reflection API:
Actionscript:
-
var instance:MyClass = new com.domain.MyClass();
-
-
// get the type info of the instance variable
-
var type:Type = Type.forInstance(instance);
-
// ... or via the class object
-
//var type:Type = Type.forClass(MyClass);
-
// ... or via the class name
-
//var type:Type = Type.forName("MyClass");
-
-
// we now have access to the properties and methods
-
// defined by the MyClass class
-
trace(type.name); // outputs "MyClass"
-
trace(type.fullName); // outputs "com.domain::MyClass"
-
trace(type.methods);
-
trace(type.staticConstants);
-
trace(type.staticVariables);
-
trace(type.constants);
-
trace(type.variables);
-
// ... and lots more
-
-
// it is also possible to dynamically invoke methods
-
var result:* = type.methods[0].invoke(instance, arg1, arg2);
General info and downloads
New Developer for Prana
Other news is that my co-worker Kristof "Hickey" Neirynck has joined the development team. Welcome Kristof!
Hope you enjoy it! As usual, any feedback is kindly appreciated.
Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
Christophe Herreman is a software developer living in Belgium. He's working on high-end Flex and AIR solutions at 
June 12th, 2007 at 2:48 am
thanks
great work. I will play with it over the weekend
cheers!
August 31st, 2007 at 12:00 pm
Hello. Could you give a hint of library reflection. I.e. how can I programmatically find out which classes are included in SWC or application. I’d like to have a list of classes like ["com.example.flex:MyClass", "com.example.flex:MyClass2", ...]
Thank you for ideas!
October 17th, 2007 at 4:15 am
Hi, How far did you get with your mock testing framework? I am playing with the idea of implementing a mock object framework in AS3.
November 6th, 2007 at 7:23 pm
Hello,
How can I accomplish in AS the java equivalent of below? I want to dynamically invoke a method:
Class c = IncidentRules.class;
Class[] parameterTypes = null;
Method methodName;
methodName = c.getMethod(“validate”+commandName,parameterTypes);
methodName.setAccessible(true);
methodName.invoke(this,null);
March 21st, 2008 at 2:31 pm
In AS3 you can use [ and ] to accomplish that:
c["validate" + commandName]();
or:
methodReference = c["validate" + commandName];
methodReference();
or:
methodReference.apply(null, []);
or:
methodReference.call(null);
Greetz Erik