Thank you guys for your explanations. Things about flash compiler with AS2 are now clearer for me.
More and more i thing over migration to AS3 and AS Virtual Machine 2..... :) P. -----Původní zpráva----- From: "Muzak" [EMAIL PROTECTED] Date: Sun, 27 May 2007 10:40:43 +0200 To: "Pavel Krusek" [EMAIL PROTECTED], [email protected] Subject: Re: [Flashcoders] AS 2 -> access to private method in decorator pattern > Because decoratorInstance is typed as Object, which is dynamic. > > You shouldn't be calling methods on the parent anyway, but just dispatch an > event to which the parent (or whoever is interested) > listens. > > // not tested so might be some errors in there > > import mx.utils.Delegate; > import mx.events.EventDispatcher; > class MenuItem extends MovieClip() { > // initialize eventdispatcher - mixin > private static var dispatcherInit = > EventDispatcher.initialize(MenuItem.prototype); > > // define eventdispatcher mixin methods > public var dispatchEvent:Function; > public var addEventListener:Function; > public var removeEventListener:Function; > > private var some_mc:MovieClip; > > public function MenuItem() { > this.init(); > } > > private function init():Void { > this.some_mc.onRelease = Delegate.create(this, this.mcReleaseHandler); > } > > private function mcReleaseHandler():Void { > this.dispatchEvent({type:"click"}); > } > } > > > import mx.utils.Delegate; > class Menu extends MovieClip > > private var menuItem:MenuItem; > > public function Menu() { > this.init(); > } > > private function init():Void { > this.createChildren(); > } > > private function createChildren():Void { > var mc:MovieClip = this.attachMovie("MenuItem", "menuItem", > this.getNextHighestDepth()); > mc.addEventListener("click", Delegate.create(this, > this.menuItemClickHandler)); > } > > private function menuItemClickHandler(o:Object):Void { > trace("target: "+o.target); > } > } > > > regards, > Muzak > > ----- Original Message ----- > From: "Pavel Krusek" <[EMAIL PROTECTED]> > To: <[email protected]> > Sent: Sunday, May 27, 2007 9:48 AM > Subject: [Flashcoders] AS 2 -> access to private method in decorator pattern > > > > Hi there, > > > > i have class Menu. > > > > In this class i attach some movie clips -> > > > > this.mcItem = > > this.attachMovie("MenuItem","MenuItem"+this.getNextHighestDepth().toString(),this.getNextHighestDepth(),{_x:x,decorateInstance:this,ident:i}); > > > > Class MenuItem > > > > > > > class MenuItem extends MovieClip > > { > > ..... > > .... > > .... > > private var decorateInstance:Object; > > .... > > .... > > ... > > > > And later in class MenuItem, in some mouse 'onRelease' event handler, i`m > > calling method in Menu class through decorateInstance: > > > > this.decorateInstance.someMethod(args....); > > > > 'someMethod' in Menu class is private (i only wanted to try it) and all > > working OK. > > Why it is possible (accessibility of private method from another class)? > > > > thanks > > > > Pavel > > > > _______________________________________________ [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

