Re: [Flashcoders] functions for other classes within a class
Have the portfolio dispatch an "init" event, just like it dispatches the "onClick" event (which you probably should just call "click"). And use the Delegate proxy class as well while you're at it. import mx.utils.Delegate; class com.tequila.canon.PosterArtist.Controller { private var portfolio:MovieClip; public function Controller() { trace("Controller constructor: " + this.portfolio); this.portfolio.addEventListener("click", Delegate.create(this, this.portfolioClickHandler)); this.portfolio.addEventListener("init", Delegate.create(this, this.portfolioInitHandler)); } private function portfolioClickHandler():Void{ trace("portfolioClickHandler: " + this); } private function portfolioInitHandler():Void{ trace("portfolioInitHandler: " + this); this.portfolio.flipCorner("bottom_right"); } } regards, Muzak - Original Message - From: "Giles Roadnight" <[EMAIL PROTECTED]> To: Sent: Friday, May 25, 2007 5:13 PM Subject: [Flashcoders] functions for other classes within a class > Hi All > > I have this code within a class: > > class com.tequila.canon.PosterArtist.Controller { > >private var portfolio:MovieClip; > >public function Controller() >{ >trace("Controller constructor: " + this.portfolio); > >this.portfolio.addEventListener("onClick",this); > >this.portfolio.onInit = this.portfolioOnInit; >} > >private function portfolioOnInit():Void >{ >trace("onInit: " + this); >this.flipCorner("bottom_right"); >} > > } > > But I get a compile error saying that flipCorner does not exist. It doesn't > exist in COntroller but it does exist in portfolio. > > How do I get around this? > > Many Thanks > > Giles. ___ 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
Re: [Flashcoders] functions for other classes within a class
Aha - it works!!! Thanks :) On 5/25/07, Jobe Makar <[EMAIL PROTECTED]> wrote: Hi, Replace this: this.flipCorner("bottom_right"); With this: portfolio.flipCorner("bottom_right"); Jobe Makar http://www.electrotank.com http://www.electro-server.com phone: 252-627-8026 mobile: 919-609-0408 fax: 919-882-1121 - Original Message - From: "Giles Roadnight" <[EMAIL PROTECTED]> To: Sent: Friday, May 25, 2007 11:13 AM Subject: [Flashcoders] functions for other classes within a class > Hi All > > I have this code within a class: > > class com.tequila.canon.PosterArtist.Controller { > >private var portfolio:MovieClip; > >public function Controller() >{ >trace("Controller constructor: " + this.portfolio); > >this.portfolio.addEventListener("onClick",this); > >this.portfolio.onInit = this.portfolioOnInit; >} > >private function portfolioOnInit():Void >{ >trace("onInit: " + this); >this.flipCorner("bottom_right"); >} > > } > > But I get a compile error saying that flipCorner does not exist. It > doesn't > exist in COntroller but it does exist in portfolio. > > How do I get around this? > > Many Thanks > > Giles. > ___ > 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
Re: [Flashcoders] functions for other classes within a class
Thanks for the reply but with this code (and variations including the code you sent): import mx.utils.Delegate; class com.tequila.canon.PosterArtist.Controller { private var portfolio:MovieClip; public function Controller() { trace("Controller constructor: " + this.portfolio); this.portfolio.addEventListener("onClick",this); //this.portfolio.onInit = this.portfolioOnInit; this.portfolio.onInit = Delegate.create(this.portfolio, this.portfolioOnInit); } private function portfolioOnInit():Void { trace("onInit: " + this); this.flipCorner("bottom_right"); } } I still get this error: **Error** C:\Documents and Settings\giles roadnight\workspace\Poster Artist\com\tequila\canon\PosterArtist\Controller.as: Line 22: There is no method with the name 'flipCorner'. this.flipCorner("bottom_right"); Total ActionScript Errors: 1 Reported Errors: 1 Thanks On 5/25/07, Johannes Nel <[EMAIL PROTECTED]> wrote: use mx.utils.Delegate to assign the function this.portfolio.onInit = Delegate.create(this,portfolioOnInit); On 5/25/07, Giles Roadnight <[EMAIL PROTECTED]> wrote: > > Hi All > > I have this code within a class: > > class com.tequila.canon.PosterArtist.Controller { > > private var portfolio:MovieClip; > > public function Controller() > { > trace("Controller constructor: " + this.portfolio); > > this.portfolio.addEventListener("onClick",this); > > this.portfolio.onInit = this.portfolioOnInit; > } > > private function portfolioOnInit():Void > { > trace("onInit: " + this); > this.flipCorner("bottom_right"); > } > > } > > But I get a compile error saying that flipCorner does not exist. It > doesn't > exist in COntroller but it does exist in portfolio. > > How do I get around this? > > Many Thanks > > Giles. > ___ > 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 > -- j:pn http://www.lennel.org ___ 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
Re: [Flashcoders] functions for other classes within a class
On 5/25/07, Giles Roadnight <[EMAIL PROTECTED]> wrote: Hi All I have this code within a class: class com.tequila.canon.PosterArtist.Controller { private var portfolio:MovieClip; public function Controller() { trace("Controller constructor: " + this.portfolio); this.portfolio.addEventListener("onClick",this); this.portfolio.onInit = this.portfolioOnInit; } private function portfolioOnInit():Void { trace("onInit: " + this); this.flipCorner("bottom_right"); } } But I get a compile error saying that flipCorner does not exist. It doesn't exist in COntroller but it does exist in portfolio. How do I get around this? Many Thanks Giles. The best solution would be to create a Portfolio class and make an onInit() function there (or just override onLoad()). Is there any reason why you can't do that? If you really, really, really need to get around it, you can do this: this["flipCorner"]("bottom_right"); ... but that's a hack for sure. A few other points: class com.tequila.canon.PosterArtist.Controller { Common convention is for packages to be in lower case, or camel-humped (e.g. posterArtist--please ignore AS2's TextField.StyleSheet). (Maybe you have a good reason for doing this, though, I dunno.) this.portfolio.addEventListener("onClick",this); Since portfolio is of type "MovieClip", there is no guarantee that it even has the function addEventListener(). This is another reason for making an actual Portfolio class. Also, while you can add an object as a listener with AS2's EventDispatcher class: 1) it has to be a function in AS3, and 2) Controller would have to have either an "onClick" method or a "handleEvent" method for this to work. Finally, common convention in AS3 is for event types not to start with "on" (although listeners to those events often start with "on"). -- Mike Keesey ___ 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
Re: [Flashcoders] functions for other classes within a class
Since that function is a class function the compiler assumes it will only be called with that class as the context. Since Controller doesn't have the function then it won't compile. What I would do is this: import mx.utils.Delegate; class com.tequila.canon.PosterArtist.Controller { private var portfolio:MovieClip; public function Controller() { trace("Controller constructor: " + this.portfolio); this.portfolio.addEventListener("onClick",this); this.portfolio.onInit = Delegate.create(this, this.portfolioOnInit); } private function portfolioOnInit():Void { trace("onInit: " + this); this.portfolio.flipCorner("bottom_right"); } } That way your class function is always called with the right context (this value). -andy On 5/25/07, Giles Roadnight <[EMAIL PROTECTED]> wrote: Hi All I have this code within a class: class com.tequila.canon.PosterArtist.Controller { private var portfolio:MovieClip; public function Controller() { trace("Controller constructor: " + this.portfolio); this.portfolio.addEventListener("onClick",this); this.portfolio.onInit = this.portfolioOnInit; } private function portfolioOnInit():Void { trace("onInit: " + this); this.flipCorner("bottom_right"); } } But I get a compile error saying that flipCorner does not exist. It doesn't exist in COntroller but it does exist in portfolio. How do I get around this? Many Thanks Giles. ___ 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
Re: [Flashcoders] functions for other classes within a class
Hi, Replace this: this.flipCorner("bottom_right"); With this: portfolio.flipCorner("bottom_right"); Jobe Makar http://www.electrotank.com http://www.electro-server.com phone: 252-627-8026 mobile: 919-609-0408 fax: 919-882-1121 - Original Message - From: "Giles Roadnight" <[EMAIL PROTECTED]> To: Sent: Friday, May 25, 2007 11:13 AM Subject: [Flashcoders] functions for other classes within a class Hi All I have this code within a class: class com.tequila.canon.PosterArtist.Controller { private var portfolio:MovieClip; public function Controller() { trace("Controller constructor: " + this.portfolio); this.portfolio.addEventListener("onClick",this); this.portfolio.onInit = this.portfolioOnInit; } private function portfolioOnInit():Void { trace("onInit: " + this); this.flipCorner("bottom_right"); } } But I get a compile error saying that flipCorner does not exist. It doesn't exist in COntroller but it does exist in portfolio. How do I get around this? Many Thanks Giles. ___ 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
Re: [Flashcoders] functions for other classes within a class
use mx.utils.Delegate to assign the function this.portfolio.onInit = Delegate.create(this,portfolioOnInit); On 5/25/07, Giles Roadnight <[EMAIL PROTECTED]> wrote: Hi All I have this code within a class: class com.tequila.canon.PosterArtist.Controller { private var portfolio:MovieClip; public function Controller() { trace("Controller constructor: " + this.portfolio); this.portfolio.addEventListener("onClick",this); this.portfolio.onInit = this.portfolioOnInit; } private function portfolioOnInit():Void { trace("onInit: " + this); this.flipCorner("bottom_right"); } } But I get a compile error saying that flipCorner does not exist. It doesn't exist in COntroller but it does exist in portfolio. How do I get around this? Many Thanks Giles. ___ 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 -- j:pn http://www.lennel.org ___ 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] functions for other classes within a class
Hi All I have this code within a class: class com.tequila.canon.PosterArtist.Controller { private var portfolio:MovieClip; public function Controller() { trace("Controller constructor: " + this.portfolio); this.portfolio.addEventListener("onClick",this); this.portfolio.onInit = this.portfolioOnInit; } private function portfolioOnInit():Void { trace("onInit: " + this); this.flipCorner("bottom_right"); } } But I get a compile error saying that flipCorner does not exist. It doesn't exist in COntroller but it does exist in portfolio. How do I get around this? Many Thanks Giles. ___ 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