Thanks David, For some odd reason if I do in my coopy
public function init():Void { trace("init in copy class"); } it wont fire but it will fire the init method from the Original Class (which by the way seem very similar to inheritance :) ).... any ideas why this could be happening? Thanks again... On 6/8/07, David Ngo <[EMAIL PROTECTED]> wrote:
You'd basically create a 'wrapper' method: class CopyClass { private var original:OriginalClass; private var mc:MovieClip; public function CopyClass(mc:MovieClip) { this.mc = mc; original = new OriginalClass(mc); } public function init():Void { original.init(); } } It's almost like calling super. However, if you're looking to override the original class' init(), then you don't need to call original.init() and just create your logic in your CopyClass' init method. This is the one drawback to using Composition over Inheritance, but I would say it's worth it in the long-run. David -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Helmut Granda Sent: Friday, June 08, 2007 10:27 AM To: Flashcoders mailing list Subject: [Flashcoders] Composition access I am slowly moving from inheritance to composition for a specific project, one way to "extend" my classes is by creating a copy of them into the new created classes... class OriginalClass { var mc:MovieClip; function original(mc:MovieClip) { this.mc = mc; init(); }; function init() { trace("original"); } ------ now trying to overwrite init class CopyClass { var original : OriginalClass; var mc : MovieClip; function CopyClass(mc:MovieClip) { this.mc = mc; original = new OriginalClass(mc); } //How do I access init from the original class? I know that doing inheritance I can just declare a new init method in my CopyClass but in this case it doesnt work that way. TIA _______________________________________________ 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
_______________________________________________ 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