Or you could use delegate to deal with any scope issues And if Element extends MovieClip you may want to place them in onLoad for good practice. Public function onLoad( event : Object ) : Void { mc.addEventListener("ALL", Delegate.create( this, handlerMethodName )) }
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lanny McNie Sent: Friday, 20 January 2006 9:40 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] addEventListener - MovieClip wants to pass event tocontaining class Thats not how EventDispatcher works. Firstly, you need a movieclip whose class has EventDispatcher tied into it (like the v2 components do). Once that's working, the correct syntax is: mc.addEventListener("click", this); function click() { // do stuff } On 1/19/06, Steve Warren <[EMAIL PROTECTED]> wrote: > > Hey folks, > > I'm having a little trouble getting addEventListener to work. I've tried > a > bunch of combinations, but have yet to find the right one. I'm trying to > assign onRelease functions to a bunch of buttons in my LanguageChooser > class. All I want to do is call a function inside LanguageChooser, > telling > it which button was clicked. Can I do it simply like this, or do I need > to > create a separate class for the button MovieClips? > > //THIS IS THE PART THAT'S NOT WORKING > english.onRelease = french.onRelease = german.onRelease = > spanish.onRelease = > addEventListener(this, languageClicked); > > Thanks in advance for any help! > > -steve > > import mx.utils.Delegate; > import mx.events.EventDispatcher; > import com.mosesSupposes.fuse.Fuse; > import com.mosesSupposes.fuse.ZigoEngine; > import com.myClient.Element; > import com.myClient.Language; > > class LanguageChooser extends Element > { > //movieclip children > private var english:MovieClip; > private var french:MovieClip; > private var german:MovieClip; > private var spanish:MovieClip; > > public var addEventListener:Function; > public var removeEventListener:Function; > public var dispatchEvent:Function > > public function LanguageChooser() > { > super(); > position(); > setup(); > transitionIn(); > } > > private function setup(Void) : Void > { > //THIS IS THE PART THAT'S NOT WORKING > english.onRelease = french.onRelease = german.onRelease = > spanish.onRelease = > addEventListener(this, languageClicked); > > english.onRollOver = french.onRollOver = german.onRollOver = > spanish.onRollOver = > function() {ZigoEngine.removeTween(this); ZigoEngine.doTween > (this, > "_y", -4, 0.08, "linear");}; > english.onRollOut = french.onRollOut = german.onRollOut = > spanish.onRollOut = > english.onReleaseOutside = french.onReleaseOutside = > german.onReleaseOutside = spanish.onReleaseOutside = > function() {ZigoEngine.removeTween(this); ZigoEngine.doTween > (this, > "_y", 0, 0.5, "easeOutCubic");}; > } > > private function languageClicked(eventObj:Object){ > trace(eventObj.target + ": " + eventObj.type); > Language.setLanguage(eventObj._name); > } > _______________________________________________ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- ------------------------- Lanny McNie _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders