Re: [Flashcoders] addEventListener - MovieClip wants to pass event to containing class
Thanks for the tips Moses! I'm gonna download and check out CallbackDispatcher 2.0 now... Where are you from? I'm living in NJ, working in Manhattan. -steve On 2/12/06, Moses Gunesch <[EMAIL PROTECTED]> wrote: > > Steve - > > Yes there are 2 things available for this. MM added that > functionality in some event classes that are pretty much undocumented > and a little tough to learn - UIEventDispatcher and LowLevelEvents. > > Secondly, I wrote a class called CallbackDispatcher that makes it > really easy to use events to scope simple callbacks wherever you > want. It's available free at my website and includes a comparison & > example of the MM system. > > You can specify an event prefix like "evt_" then name your events > like "evt_onRollOver", or use Delegates as shown here, to route any > built-in MC, Button, or TextField callbacks to a uniquely named > method. This really helps keep scoping mouse events tidy and also > gives you an opportunity to group the events for some subset of nav > elements into smartly named handlers, like "handleNavEvent" in this > example which will do rollover/out and onpress actions - keeps your > classes neat. (Again, the use of Delegate is entirely optional.) > > var navDel:Function = Delegate.create(this, handleNavEvent); > CallbackDispatcher.initialize(mc); > mc.addEventListener ('onRollOver, onRollOut, onPress', navDel); > > function handleNavEvent(o:Object) { > trace(o.target._name+'.'+o.type); > switch(o.type) { > // etc.. > } > } > > download at: http://www.mosessupposes.com/utilities/index.html > > Hope that helps you out! > - Moses > > > On Jan 19, 2006, at 2:33 PM, Steve Warren wrote: > > > 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. > ___ > 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] addEventListener - MovieClip wants to pass event to containing class
Steve - Yes there are 2 things available for this. MM added that functionality in some event classes that are pretty much undocumented and a little tough to learn - UIEventDispatcher and LowLevelEvents. Secondly, I wrote a class called CallbackDispatcher that makes it really easy to use events to scope simple callbacks wherever you want. It's available free at my website and includes a comparison & example of the MM system. You can specify an event prefix like "evt_" then name your events like "evt_onRollOver", or use Delegates as shown here, to route any built-in MC, Button, or TextField callbacks to a uniquely named method. This really helps keep scoping mouse events tidy and also gives you an opportunity to group the events for some subset of nav elements into smartly named handlers, like "handleNavEvent" in this example which will do rollover/out and onpress actions - keeps your classes neat. (Again, the use of Delegate is entirely optional.) var navDel:Function = Delegate.create(this, handleNavEvent); CallbackDispatcher.initialize(mc); mc.addEventListener ('onRollOver, onRollOut, onPress', navDel); function handleNavEvent(o:Object) { trace(o.target._name+'.'+o.type); switch(o.type) { // etc.. } } download at: http://www.mosessupposes.com/utilities/index.html Hope that helps you out! - Moses On Jan 19, 2006, at 2:33 PM, Steve Warren wrote: 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. ___ 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] addEventListener - MovieClip wants to pass event to containing 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] addEventListener - MovieClip wants to pass event to containing class
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