Hello :) try this code :
class Component extends MovieClip { // constructor function Component() { } ///////////// Init AsBroadcaster static private var _INIT_BROADCASTER_ = _global.AsBroadcaster.initialize( Component.prototype ) ; public var addListener:Function ; public var broadcastMessage:Function ; public var removeListener:Function ; ///////////// public function onPress():Void { // your code this.broadcastMessage( "onClick" , this) ; } } If you want use a method inside the class... no problemo but now if you want use a listener and a movieclip who extend this class : var mc:MovieClip ; // the movieclip in the _root for example // Inherit the custom class mc.__proto__ = Component.prototype ; Component.prototype.call(mc) ; mc.addListener(this) ; this.onClick = function ( target:MovieClip ) { trace( "click " : target ) ; } If you want a better solution .. you can use my openSource framework VEGAS ( http://vegas.riaforge.org/ ) and the package vegas.util.factory.. in this package you can find the class DisplayFactory : http://svn.riaforge.org/vegas/AS2/trunk/src/vegas/util/factory/DisplayFactory.as If you want test this class.. 1 - download vegas 2 - install in your actionscript preference (in flash) the classpath of vegas in AS2/trunk/src 3 - Test the examples in AS2/trunk/bin/test/vegas/util/factory : http://svn.riaforge.org/vegas/AS2/trunk/bin/test/vegas/util/factory/ You can use the composition pattern and not the extend pattern to control a movieclip... in my framework you can use the DisplayObject AS2 class in the asgard.display package. EKA+ :) 2007/2/4, David Cohn <[EMAIL PROTECTED]>:
Hey all, Is it possible to use a "class extends MovieClip" on a pre-existing (authored) MovieClip? I'd like to seamlessly do something like: class blah extends MovieClip { public function blah() { this.onRelease = function() { // handle release here }; }; }; ... but I can't see how to set this up (I'm using ActionScript 2.0, but is there a 3.0 only solution?). If not, what do people think is the most elegant way to handle this, e.g.: class blah { public function blah( caller:MovieClip ) { caller.onRelease = function() { (blah instance).handleRelease(); }; }; public function handleRelease() { // handle release here }; }; ...I'd like to make this as seamless as possible for the graphic designers. Thanks, --Dave _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
_______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com