Is it legal to extend the Class class?

Posted by spiralganglion on Stack Overflow See other posts from Stack Overflow or by spiralganglion
Published on 2010-04-10T18:02:55Z Indexed on 2010/04/10 19:53 UTC
Read the original article Hit count: 271

Filed under:
|
|

I've been writing a system that generates some templates, and then generates some objects based on those templates. I had the idea that the templates could be extensions of the Class class, but that resulted in some magnificent errors:

VerifyError: Error #1107: The ABC data is corrupt, attempt to read out of bounds.

What I'm wondering is if subclassing Class is even possible, if there is perhaps some case where doing this would be appropriate, and not just a gross misuse of OOP. I believe it should be possible, as ActionScript allows you to create variables of the Class type. This use is described in the LiveDocs entry for Class, yet I've seen no mentions of subclassing Class.

Here's a pseudocode example:

class Foo extends Class

var a:Foo = new Foo();
trace(a is Class) // true, right?
var b = new a();

I have no idea what the type of b would be.

In summary: can you subclass the Class class? If so, how can you do it without errors, and what type are the instances of the instances of the Class subclass?

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about flash