Do you mean that setting the associated AS 2.0 class in the
MovieClip's linkage settings is not an option and you want to alter
the class of an existing MovieClip instance at run-time? It's possible
by utilizing the __proto__ property and reorganizing the prototype
chain.

But your code seems to be not optimal:
1. unnecessary and superfluous to create a wrapper function for each
   instance's onRelease handler (it creates as many Function instances
   as many blah instance is created)
2. the same with setting the handler function in the constructor,
   since it can be a simple class member

class blah extends MovieClip {

  private function onRelease(): Void {
    // handle release here
  }

}


   Attila


DC> Hey all,
DC> 
DC> Is it possible to use a "class extends MovieClip" on a pre-existing  
DC> (authored) MovieClip?
DC> I'd like to seamlessly do something like:
DC> 
DC> class blah extends MovieClip {
DC> 
DC>     public function blah() {
DC>             this.onRelease = function() {
DC>                     // handle release here
DC>             };
DC>     };
DC> };
DC> 
DC> ... but I can't see how to set this up (I'm using ActionScript 2.0,  
DC> but is there a 3.0 only solution?).
DC> 
DC> If not, what do people think is the most elegant way to handle this,  
DC> e.g.:
DC> 
DC> class blah {
DC> 
DC>     public function blah( caller:MovieClip ) {
DC>             caller.onRelease = function() {
DC>                     (blah instance).handleRelease();
DC>             };
DC>     };
DC>     
DC>     public function handleRelease() {
DC>             // handle release here
DC>     };
DC> };
DC> 
DC> ...I'd like to make this as seamless as possible for the graphic  
DC> designers.


_______________________________________________
[email protected]
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

Reply via email to