Ok, figured out Main -method1 (calls method2) -method2 (calls method3) -method3
Copy method2 = this.method2 -method2 = calls main.method3; so you can make them talk to each other, I just was confused how to put it into code. Thanks -h On 6/8/07, Helmut Granda <[EMAIL PROTECTED]> wrote:
One more question while in Composition mode lets say I have my main class Main -method1 (calls method2) -method2 (calls method3) -method3 With Inheritance I could do Copy -method2 (calls method3 of Main) When instantiating Copy it would know to use method1, and method3 from original while using method2 from the copy. Is there a way to achieve the same issue with composition? So far thanks to the explanation above I can access the methods of Main from a Copy instantiation but cant access methods of Copy from Main when needed. I might be approaching this all wrong which might be the main issue :( TIA On 6/8/07, Helmut Granda <[EMAIL PROTECTED]> wrote: > > hey David, > > your suggestion works perfectly, it was my implementation that was > breaking the code. > > Thanks again. > -h > > On 6/8/07, Helmut Granda <[EMAIL PROTECTED]> wrote: > > > > 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