First and foremost, you should reeaalllly move on to AS3 when you first get the chance. The syntax and feature set would be much more appropriate for the stuff you're trying to do.
as for extending the movieclip class- why make use of createEmptyMovieClip when you can create an instance of your new class directly?
var myMovieCan:MovieCan = new MovieCan();
this is effectively the same as creating an empty movieclip, but now it has the functionality of whatever MovieCan implemented. But you're right, you couldn't apply this to the root. I'm getting a bit rusty on my AS2 implementations so I'll stop here before I butcher it.
FOR AS3:
Key listeners are handled by the stage only, not individual objects. Also, both textfields and movieclip are subclasses of displayobject. So if you want to clear the screen, or even just an individual object, I'd suggest simply creating a utility function to do so
static function clearDisplayObject(obj:DisplayObject):void
{
while(obj.numChildren > 0)
{
var curChild:DisplayObject = obj.getChildAt(0);
curChild.dispose();
obj.removeChild(curChild);
}
}
This would remove all children from the given display object's list. Once removed from a display list, the object will be cleaned up by the garbage collector UNLESS there are still references to it. The most common source of remaining references are those created by event listeners. This is where the dispose method comes in. Dispose() is something you would need to define yourself, a custom method that would remove an object's event listeners. The object itself needs to handle this because we do not yet have a way of iterating an object's listeners like we do with its children.
That's all well and good, but what if the object in question has no event listeners? What if the object is a basic sprite or movieclip that hasn't been subclassed into anything? Here you could consider implementing a 'disposable' interface, where any class that needs this functionality is required to implement a dispose method. (thanks to mike for the tip on this!)
public interface Disposable
{
public function dispose():void;
}
then we can modify our previous code to act accordingly
if(curChild is Disposable)curChild.dispose();
obj.removeChild(curChild);
What about basic sprites and movieclips that have no subclass but do have event listeners? I make it personal practice that any object needing event listeners also needs its own subclass, so that's never an issue for me.
Since the root is of type MovieClip, you can simply do
clearDisplayObject(root);
that only works from the main timeline though, anywhere else it would need to be part of a display object that has already been added to a display list, so that it has access to the root property.
Lastly, you may be interested to know that AS3 supports 'document classes.' Basically, a class that represents the root itself. For example I use a class called Game, which extends MovieClip (it has no other choice). The constructor of this class serves as the program's main point of entry.
I am still learning a lot about AS3 as I go, so I would love to hear any comments, critiques, or corrections that anyone has to offer.
There are a lot of ways to approach this problem so I hope this provided at least a little insight.