How do I get from an instance of a class to a Class object in ActionScript 3?

actionscript, actionscript-3, apache-flex, flash

Solution

You can get it through the 'constructor' property of the base Object class. i.e.:

var myClass:Class = Object(myObj).constructor;

Problem

How do you get an instance of the actionscript class `Class` from an instance of that class? In Python, this would be `x.__class__`; in Java, `x.getClass();`. I'm aware that certain terrible hacks exist to do this, but I'm looking for a built-in language facility, or at least a library routine built on something reliable.

Original source

Related problems