To complete Christian's answer:
var cls : Class = loader.contentLoaderInfo.applicationDomain.getDefinition("ClassName");
var instance : Object = new cls();
Additionally, it's worth noting that you won't get strong typing (ie. it must be declared as Object) unless the class implements interface which is also defined in your main application. You will then be able to declare the instance variable as the interface and have compile-time access to it's members.
In realy I advise to you don't to use this too much... it is very expensive. Adobe need to create a native function to return this to us.
But, for now... try this:
You will need to cause a explicit coercion to get it!
Because when you make and explicit coercion you get an Error like this:
TypeError: Error #1034:
Type Coercion failed: cannot convert Main@1c49d31 to flash.utils.ByteArray.
Note that in this error you get what you want... the @1c49d31. This hash is like an ID in the memory allocation.
I did a lot of tests. This hash just change when you call a "new" (in C languages is equivalent to [[... alloc] init]) and for static functions and static properties, the allocation occurs a little different... anyway...
Backing to Flash, the problem is we don't have a direct way to get this hash without an Error.
But this is not a realy big problem. All that you need is to use some "try" and "catch"
Like this:
try
{
ByteArray(anyObjectToKnowItAllocationHash);
}
catch (e:Error)
{
trace(e);
}
And voila!
You will get the hash without result in an Error!
After this I did a more refinated way... Try this:
var memoryHash:String;
try
{
FakeClass(anyObjectToKnowItAllocationHash);
}
catch (e:Error)
{
memoryHash = String(e).replace(/.*([@|\$].*?) to .*$/gi, '$1');
}
internal final class FakeClass { }
A little explain about this:
The fakeClass is to be sure about this will generate an Error.
The RegularExpression is to capture the last @... that appear. Because Objects and Functions generate different messages on this Error. And the $ is to catch the Static Objects, Class and Functions, bacause they don't have an "@" in its memory hash and different zones in memory.
This little code works so fine to me! Now i can finish some great engines that i'm making that work with memory management, weak references and ID based on memory.
I hope this can help you.
Bye, and good luck, my friend!
Best Solution
If it's a dynamic object I believe you can just do something like this:
That's how it's done in AS2, and I believe that still works for dynamic objects in AS3. I think the properties that it will show is more limited on non-dynamic objects.