Re: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
Hi Gordon, Is this a documented behaviour or just the current implementation? Where can we find the documentation? Cheers Ralf. On 2/9/07, Gordon Smith [EMAIL PROTECTED] wrote: Didn't I read somewhere that the order you add listeners is the order they get dispatched in as3 now? That's correct.
RE: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
It should be documented, but I'm not sure that it is. I can't find it in the ASDoc, for example, which doesn't seem to discuss the case of registering multiple listeners for the same event with the same priority. - Gordon From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Ralf Bokelberg Sent: Friday, February 09, 2007 12:53 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML Hi Gordon, Is this a documented behaviour or just the current implementation? Where can we find the documentation? Cheers Ralf. On 2/9/07, Gordon Smith [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Didn't I read somewhere that the order you add listeners is the order they get dispatched in as3 now? That's correct.
RE: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
It is documented, in two places: 1) ActionScript Language Reference: http://www.adobe.com/livedocs/flex/201/langref/flash/events/EventDispatc her.html In the method detail for flash.events.EventDispatcher.addEventListener() see the description of the priority parameter: If two or more listeners share the same priority, they are processed in the order in which they were added. 2) Programming ActionScript 3.0 (chapter on Event Handling) http://www.adobe.com/livedocs/flex/201/html/16_Event_handling_172_6.html #119538 See the subsection titled Adding Event Listeners and the paragraph that discusses the priority parameter. The last sentence reads: Event listeners with the same priority are executed in the order that they were added, so the earlier a listener is added, the sooner it will be executed. HTH, Francis From: Gordon Smith Sent: Friday, February 09, 2007 9:58 AM To: flexcoders@yahoogroups.com Cc: DL-Flash Player IMD Subject: RE: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML It should be documented, but I'm not sure that it is. I can't find it in the ASDoc, for example, which doesn't seem to discuss the case of registering multiple listeners for the same event with the same priority. - Gordon From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Ralf Bokelberg Sent: Friday, February 09, 2007 12:53 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML Hi Gordon, Is this a documented behaviour or just the current implementation? Where can we find the documentation? Cheers Ralf. On 2/9/07, Gordon Smith [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Didn't I read somewhere that the order you add listeners is the order they get dispatched in as3 now? That's correct.
RE: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
Thanks, Francis. Sorry I didn't read the ASDoc carefully enough! - Gordon From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Francis Cheng Sent: Friday, February 09, 2007 10:26 AM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML It is documented, in two places: 1) ActionScript Language Reference: http://www.adobe.com/livedocs/flex/201/langref/flash/events/EventDispatc her.html http://www.adobe.com/livedocs/flex/201/langref/flash/events/EventDispat cher.html In the method detail for flash.events.EventDispatcher.addEventListener() see the description of the priority parameter: If two or more listeners share the same priority, they are processed in the order in which they were added. 2) Programming ActionScript 3.0 (chapter on Event Handling) http://www.adobe.com/livedocs/flex/201/html/16_Event_handling_172_6.html #119538 http://www.adobe.com/livedocs/flex/201/html/16_Event_handling_172_6.htm l#119538 See the subsection titled Adding Event Listeners and the paragraph that discusses the priority parameter. The last sentence reads: Event listeners with the same priority are executed in the order that they were added, so the earlier a listener is added, the sooner it will be executed. HTH, Francis From: Gordon Smith Sent: Friday, February 09, 2007 9:58 AM To: flexcoders@yahoogroups.com Cc: DL-Flash Player IMD Subject: RE: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML It should be documented, but I'm not sure that it is. I can't find it in the ASDoc, for example, which doesn't seem to discuss the case of registering multiple listeners for the same event with the same priority. - Gordon From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Ralf Bokelberg Sent: Friday, February 09, 2007 12:53 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML Hi Gordon, Is this a documented behaviour or just the current implementation? Where can we find the documentation? Cheers Ralf. On 2/9/07, Gordon Smith [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Didn't I read somewhere that the order you add listeners is the order they get dispatched in as3 now? That's correct.
RE: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
Thanks for the using a Constant tip - as I agree with you. Using a constant, will automatically grab any new values, in case any changes are made in future releases. I was going to make all these changes eventually, but now I think I will speed up that process, as I comb through my source code during my Map Application (Flash-Flex) upgrade. Thanks again for all your input on this topic - believe me, it's helping me a LOT - Mike From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Doug McCune Sent: Wednesday, February 07, 2007 11:53 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML Nope, I think the second parameter must be a function, trying to pass an array of functions should fail. Also, just a note: it's better practice to not use the string of the event listener like click but rather the variable like MouseEvent.CLICK. They really do the exact same thing in practice, but it's possible that within MouseEvent the click event could be renamed in a future release to something like mouseClick and then your code wouldn't work. Doug Mike Anderson wrote: Hey Doug, Well, that's simple enough. Probably so simple, that I simply overlooked doing it that way. Real quick, would it be possible to also do it this way? Object.addEventListener( click, [funct1, funct2, funct3] ); I know I could just try it, but from a methodology point of view, it would be nice to know if this was a valid way to do it. Thanks! Mike -Original Message- From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of dougmccune Sent: Wednesday, February 07, 2007 10:10 AM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML You can make as many calls to addEventListener as you want. So you can add 2 or more event listeners that get triggered for the same event. So something like: myButton.addEventListener(MouseEvent.CLICK, myFunction1); myButton.addEventListener(MouseEvent.CLICK, myFunction2); myButton.addEventListener(MouseEvent.CLICK, myFunction3); All three of the above functions would get called when the event triggers. You can remove each of these separately as well by using removeEventListener and specifying the particular function you want removed. Doug --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Mike Anderson [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hello All, I have a problem, and maybe I am overlooking something here... What I need to do, is attach multiple functions, to an Event for a particular Component. Using inline MXML, this is easy - you just separate out each function, with a semi-colon and list them one after another. BUT, I am trying NOT to put my functions within the MXML - I am using Code-Behind, and I need to add my Event Listeners within the ActionScript - using the Object.addEventListener() method. Thing is, how do I add several functions using this type of methodology? Or can it even be done? Thanks in advance for any help you can offer regarding this, Mike -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links
Re: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
Yes that's possible, but semantically it is slightly different. Inside the binding tag, the sequence of function calls is given by the sequence in your code. If you use mulitple addEventListener calls the sequence is not guaranteed. Another possibility, which maintains the sequence, would be to use an anonymous function myButton.addEventListener( MouseEvent.CLICK, function(){ myFunction1(); myFunction2(); myFunction3(); }) Cheers, Ralf. On 2/7/07, dougmccune [EMAIL PROTECTED] wrote: You can make as many calls to addEventListener as you want. So you can add 2 or more event listeners that get triggered for the same event. So something like: myButton.addEventListener(MouseEvent.CLICK, myFunction1); myButton.addEventListener(MouseEvent.CLICK, myFunction2); myButton.addEventListener(MouseEvent.CLICK, myFunction3); All three of the above functions would get called when the event triggers. You can remove each of these separately as well by using removeEventListener and specifying the particular function you want removed. Doug --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Mike Anderson [EMAIL PROTECTED] wrote: Hello All, I have a problem, and maybe I am overlooking something here... What I need to do, is attach multiple functions, to an Event for a particular Component. Using inline MXML, this is easy - you just separate out each function, with a semi-colon and list them one after another. BUT, I am trying NOT to put my functions within the MXML - I am using Code-Behind, and I need to add my Event Listeners within the ActionScript - using the Object.addEventListener() method. Thing is, how do I add several functions using this type of methodology? Or can it even be done? Thanks in advance for any help you can offer regarding this, Mike -- Ralf Bokelberg [EMAIL PROTECTED] Flex Flash Consultant based in Cologne/Germany Phone +49 (0) 221 530 15 35
Re: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
removing this listener would be tricky however. On 2/8/07, Ralf Bokelberg [EMAIL PROTECTED] wrote: Yes that's possible, but semantically it is slightly different. Inside the binding tag, the sequence of function calls is given by the sequence in your code. If you use mulitple addEventListener calls the sequence is not guaranteed. Another possibility, which maintains the sequence, would be to use an anonymous function myButton.addEventListener( MouseEvent.CLICK, function(){ myFunction1(); myFunction2(); myFunction3(); }) Cheers, Ralf. On 2/7/07, dougmccune [EMAIL PROTECTED] wrote: You can make as many calls to addEventListener as you want. So you can add 2 or more event listeners that get triggered for the same event. So something like: myButton.addEventListener(MouseEvent.CLICK, myFunction1); myButton.addEventListener(MouseEvent.CLICK, myFunction2); myButton.addEventListener(MouseEvent.CLICK, myFunction3); All three of the above functions would get called when the event triggers. You can remove each of these separately as well by using removeEventListener and specifying the particular function you want removed. Doug --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Mike Anderson [EMAIL PROTECTED] wrote: Hello All, I have a problem, and maybe I am overlooking something here... What I need to do, is attach multiple functions, to an Event for a particular Component. Using inline MXML, this is easy - you just separate out each function, with a semi-colon and list them one after another. BUT, I am trying NOT to put my functions within the MXML - I am using Code-Behind, and I need to add my Event Listeners within the ActionScript - using the Object.addEventListener() method. Thing is, how do I add several functions using this type of methodology? Or can it even be done? Thanks in advance for any help you can offer regarding this, Mike -- Ralf Bokelberg [EMAIL PROTECTED] Flex Flash Consultant based in Cologne/Germany Phone +49 (0) 221 530 15 35 -- j:pn http://www.lennel.org
Re: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
Ralf, That is an interesting approach. I just have never had the need for something like that.. yet. Didn't I read somewhere that the order you add listeners is the order they get dispatched in as3 now? Plus you can use priorities. PS From an OOP standpoint, I wouldn't do it , I would just write a wrapper method that calls it. Much better from a maintainence aspect and intent aspect. Peace, Mike On 2/8/07, Ralf Bokelberg [EMAIL PROTECTED] wrote: Yes that's possible, but semantically it is slightly different. Inside the binding tag, the sequence of function calls is given by the sequence in your code. If you use mulitple addEventListener calls the sequence is not guaranteed. Another possibility, which maintains the sequence, would be to use an anonymous function myButton.addEventListener( MouseEvent.CLICK, function(){ myFunction1(); myFunction2(); myFunction3(); }) Cheers, Ralf. On 2/7/07, dougmccune [EMAIL PROTECTED] wrote: You can make as many calls to addEventListener as you want. So you can add 2 or more event listeners that get triggered for the same event. So something like: myButton.addEventListener(MouseEvent.CLICK, myFunction1); myButton.addEventListener(MouseEvent.CLICK, myFunction2); myButton.addEventListener(MouseEvent.CLICK, myFunction3); All three of the above functions would get called when the event triggers. You can remove each of these separately as well by using removeEventListener and specifying the particular function you want removed. Doug --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Mike Anderson [EMAIL PROTECTED] wrote: Hello All, I have a problem, and maybe I am overlooking something here... What I need to do, is attach multiple functions, to an Event for a particular Component. Using inline MXML, this is easy - you just separate out each function, with a semi-colon and list them one after another. BUT, I am trying NOT to put my functions within the MXML - I am using Code-Behind, and I need to add my Event Listeners within the ActionScript - using the Object.addEventListener() method. Thing is, how do I add several functions using this type of methodology? Or can it even be done? Thanks in advance for any help you can offer regarding this, Mike -- Ralf Bokelberg [EMAIL PROTECTED] Flex Flash Consultant based in Cologne/Germany Phone +49 (0) 221 530 15 35 -- Teoti Graphix http://www.teotigraphix.com Blog - Flex2Components http://www.flex2components.com You can find more by solving the problem then by 'asking the question'.
Re: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
Yes Johannes Michael I'm not using it either. I just wanted to show what is possible. Since i don't use code behind, i don't have this kind of problems anyways ;) Cheers, Ralf. On 2/8/07, Michael Schmalle [EMAIL PROTECTED] wrote: Ralf, That is an interesting approach. I just have never had the need for something like that.. yet. Didn't I read somewhere that the order you add listeners is the order they get dispatched in as3 now? Plus you can use priorities. PS From an OOP standpoint, I wouldn't do it , I would just write a wrapper method that calls it. Much better from a maintainence aspect and intent aspect. Peace, Mike On 2/8/07, Ralf Bokelberg [EMAIL PROTECTED] wrote: Yes that's possible, but semantically it is slightly different. Inside the binding tag, the sequence of function calls is given by the sequence in your code. If you use mulitple addEventListener calls the sequence is not guaranteed. Another possibility, which maintains the sequence, would be to use an anonymous function myButton.addEventListener( MouseEvent.CLICK, function(){ myFunction1(); myFunction2(); myFunction3(); }) Cheers, Ralf. On 2/7/07, dougmccune [EMAIL PROTECTED] wrote: You can make as many calls to addEventListener as you want. So you can add 2 or more event listeners that get triggered for the same event. So something like: myButton.addEventListener(MouseEvent.CLICK, myFunction1); myButton.addEventListener(MouseEvent.CLICK, myFunction2); myButton.addEventListener(MouseEvent.CLICK, myFunction3); All three of the above functions would get called when the event triggers. You can remove each of these separately as well by using removeEventListener and specifying the particular function you want removed. Doug --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Mike Anderson [EMAIL PROTECTED] wrote: Hello All, I have a problem, and maybe I am overlooking something here... What I need to do, is attach multiple functions, to an Event for a particular Component. Using inline MXML, this is easy - you just separate out each function, with a semi-colon and list them one after another. BUT, I am trying NOT to put my functions within the MXML - I am using Code-Behind, and I need to add my Event Listeners within the ActionScript - using the Object.addEventListener() method. Thing is, how do I add several functions using this type of methodology? Or can it even be done? Thanks in advance for any help you can offer regarding this, Mike -- Ralf Bokelberg [EMAIL PROTECTED] Flex Flash Consultant based in Cologne/Germany Phone +49 (0) 221 530 15 35 -- Teoti Graphix http://www.teotigraphix.com Blog - Flex2Components http://www.flex2components.com You can find more by solving the problem then by 'asking the question'. -- Ralf Bokelberg [EMAIL PROTECTED] Flex Flash Consultant based in Cologne/Germany Phone +49 (0) 221 530 15 35
RE: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
Didn't I read somewhere that the order you add listeners is the order they get dispatched in as3 now? That's correct. Plus you can use priorities. This can be tricky, as the framework uses different priorities for various purposes. If you need to ensure the order in which multiple event handlers get called, try to add them in the right order. - Gordon From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Ralf Bokelberg Sent: Thursday, February 08, 2007 6:56 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML Yes Johannes Michael I'm not using it either. I just wanted to show what is possible. Since i don't use code behind, i don't have this kind of problems anyways ;) Cheers, Ralf. On 2/8/07, Michael Schmalle [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Ralf, That is an interesting approach. I just have never had the need for something like that.. yet. Didn't I read somewhere that the order you add listeners is the order they get dispatched in as3 now? Plus you can use priorities. PS From an OOP standpoint, I wouldn't do it , I would just write a wrapper method that calls it. Much better from a maintainence aspect and intent aspect. Peace, Mike On 2/8/07, Ralf Bokelberg [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Yes that's possible, but semantically it is slightly different. Inside the binding tag, the sequence of function calls is given by the sequence in your code. If you use mulitple addEventListener calls the sequence is not guaranteed. Another possibility, which maintains the sequence, would be to use an anonymous function myButton.addEventListener( MouseEvent.CLICK, function(){ myFunction1(); myFunction2(); myFunction3(); }) Cheers, Ralf. On 2/7/07, dougmccune [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: You can make as many calls to addEventListener as you want. So you can add 2 or more event listeners that get triggered for the same event. So something like: myButton.addEventListener(MouseEvent.CLICK, myFunction1); myButton.addEventListener(MouseEvent.CLICK, myFunction2); myButton.addEventListener(MouseEvent.CLICK, myFunction3); All three of the above functions would get called when the event triggers. You can remove each of these separately as well by using removeEventListener and specifying the particular function you want removed. Doug --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Mike Anderson [EMAIL PROTECTED] wrote: Hello All, I have a problem, and maybe I am overlooking something here... What I need to do, is attach multiple functions, to an Event for a particular Component. Using inline MXML, this is easy - you just separate out each function, with a semi-colon and list them one after another. BUT, I am trying NOT to put my functions within the MXML - I am using Code-Behind, and I need to add my Event Listeners within the ActionScript - using the Object.addEventListener() method. Thing is, how do I add several functions using this type of methodology? Or can it even be done? Thanks in advance for any help you can offer regarding this, Mike -- Ralf Bokelberg [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Flex Flash Consultant based in Cologne/Germany Phone +49 (0) 221 530 15 35 -- Teoti Graphix http://www.teotigraphix.com http://www.teotigraphix.com Blog - Flex2Components http://www.flex2components.com http://www.flex2components.com You can find more by solving the problem then by 'asking the question'. -- Ralf Bokelberg [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Flex Flash Consultant based in Cologne/Germany Phone +49 (0) 221 530 15 35
RE: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
Hey Doug, Well, that's simple enough. Probably so simple, that I simply overlooked doing it that way. Real quick, would it be possible to also do it this way? Object.addEventListener( click, [funct1, funct2, funct3] ); I know I could just try it, but from a methodology point of view, it would be nice to know if this was a valid way to do it. Thanks! Mike -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dougmccune Sent: Wednesday, February 07, 2007 10:10 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML You can make as many calls to addEventListener as you want. So you can add 2 or more event listeners that get triggered for the same event. So something like: myButton.addEventListener(MouseEvent.CLICK, myFunction1); myButton.addEventListener(MouseEvent.CLICK, myFunction2); myButton.addEventListener(MouseEvent.CLICK, myFunction3); All three of the above functions would get called when the event triggers. You can remove each of these separately as well by using removeEventListener and specifying the particular function you want removed. Doug --- In flexcoders@yahoogroups.com, Mike Anderson [EMAIL PROTECTED] wrote: Hello All, I have a problem, and maybe I am overlooking something here... What I need to do, is attach multiple functions, to an Event for a particular Component. Using inline MXML, this is easy - you just separate out each function, with a semi-colon and list them one after another. BUT, I am trying NOT to put my functions within the MXML - I am using Code-Behind, and I need to add my Event Listeners within the ActionScript - using the Object.addEventListener() method. Thing is, how do I add several functions using this type of methodology? Or can it even be done? Thanks in advance for any help you can offer regarding this, Mike -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links
Re: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
Object.addEventListener( click, [funct1, funct2, funct3] ); No, 1. as3 is strongly typed which means the method expects a function when it is getting an array. 2. addEventListener wouldn't even know what to do with an array. You could, if you had your own subclass override addEventListener to do that but, you could also just create a stack of functions in an array if they were all going to the same event and loop through them to save code lines. It's personal choice when you get to this point. Peace, Mike On 2/7/07, Mike Anderson [EMAIL PROTECTED] wrote: Hey Doug, Well, that's simple enough. Probably so simple, that I simply overlooked doing it that way. Real quick, would it be possible to also do it this way? Object.addEventListener( click, [funct1, funct2, funct3] ); I know I could just try it, but from a methodology point of view, it would be nice to know if this was a valid way to do it. Thanks! Mike -Original Message- From: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com [mailto: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com] On Behalf Of dougmccune Sent: Wednesday, February 07, 2007 10:10 AM To: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML You can make as many calls to addEventListener as you want. So you can add 2 or more event listeners that get triggered for the same event. So something like: myButton.addEventListener(MouseEvent.CLICK, myFunction1); myButton.addEventListener(MouseEvent.CLICK, myFunction2); myButton.addEventListener(MouseEvent.CLICK, myFunction3); All three of the above functions would get called when the event triggers. You can remove each of these separately as well by using removeEventListener and specifying the particular function you want removed. Doug --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Mike Anderson [EMAIL PROTECTED] wrote: Hello All, I have a problem, and maybe I am overlooking something here... What I need to do, is attach multiple functions, to an Event for a particular Component. Using inline MXML, this is easy - you just separate out each function, with a semi-colon and list them one after another. BUT, I am trying NOT to put my functions within the MXML - I am using Code-Behind, and I need to add my Event Listeners within the ActionScript - using the Object.addEventListener() method. Thing is, how do I add several functions using this type of methodology? Or can it even be done? Thanks in advance for any help you can offer regarding this, Mike -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Teoti Graphix http://www.teotigraphix.com Blog - Flex2Components http://www.flex2components.com You can find more by solving the problem then by 'asking the question'.
Re: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
Nope, I think the second parameter must be a function, trying to pass an array of functions should fail. Also, just a note: it's better practice to not use the string of the event listener like click but rather the variable like MouseEvent.CLICK. They really do the exact same thing in practice, but it's possible that within MouseEvent the click event could be renamed in a future release to something like mouseClick and then your code wouldn't work. Doug Mike Anderson wrote: Hey Doug, Well, that's simple enough. Probably so simple, that I simply overlooked doing it that way. Real quick, would it be possible to also do it this way? Object.addEventListener( click, [funct1, funct2, funct3] ); I know I could just try it, but from a methodology point of view, it would be nice to know if this was a valid way to do it. Thanks! Mike -Original Message- From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com] On Behalf Of dougmccune Sent: Wednesday, February 07, 2007 10:10 AM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML You can make as many calls to addEventListener as you want. So you can add 2 or more event listeners that get triggered for the same event. So something like: myButton.addEventListener(MouseEvent.CLICK, myFunction1); myButton.addEventListener(MouseEvent.CLICK, myFunction2); myButton.addEventListener(MouseEvent.CLICK, myFunction3); All three of the above functions would get called when the event triggers. You can remove each of these separately as well by using removeEventListener and specifying the particular function you want removed. Doug --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com, Mike Anderson [EMAIL PROTECTED] wrote: Hello All, I have a problem, and maybe I am overlooking something here... What I need to do, is attach multiple functions, to an Event for a particular Component. Using inline MXML, this is easy - you just separate out each function, with a semi-colon and list them one after another. BUT, I am trying NOT to put my functions within the MXML - I am using Code-Behind, and I need to add my Event Listeners within the ActionScript - using the Object.addEventListener() method. Thing is, how do I add several functions using this type of methodology? Or can it even be done? Thanks in advance for any help you can offer regarding this, Mike -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links
Re: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
could be renamed in a future release to something like mouseClick and then your code wouldn't work. Or even worse, you write cllck, and then for days even months, you think your app isn't working or 'works' a certain way. Come to find out the event wasn't even getting captured. :) This is plain ole preventative maintainence. That is the worse case for me, renaming events is small potatoes to that error. ;-) Peace, Mike On 2/7/07, Doug McCune [EMAIL PROTECTED] wrote: Nope, I think the second parameter must be a function, trying to pass an array of functions should fail. Also, just a note: it's better practice to not use the string of the event listener like click but rather the variable like MouseEvent.CLICK. They really do the exact same thing in practice, but it's possible that within MouseEvent the click event could be renamed in a future release to something like mouseClick and then your code wouldn't work. Doug Mike Anderson wrote: Hey Doug, Well, that's simple enough. Probably so simple, that I simply overlooked doing it that way. Real quick, would it be possible to also do it this way? Object.addEventListener( click, [funct1, funct2, funct3] ); I know I could just try it, but from a methodology point of view, it would be nice to know if this was a valid way to do it. Thanks! Mike -Original Message- From: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com [mailto: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com] On Behalf Of dougmccune Sent: Wednesday, February 07, 2007 10:10 AM To: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML You can make as many calls to addEventListener as you want. So you can add 2 or more event listeners that get triggered for the same event. So something like: myButton.addEventListener(MouseEvent.CLICK, myFunction1); myButton.addEventListener(MouseEvent.CLICK, myFunction2); myButton.addEventListener(MouseEvent.CLICK, myFunction3); All three of the above functions would get called when the event triggers. You can remove each of these separately as well by using removeEventListener and specifying the particular function you want removed. Doug --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Mike Anderson [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello All, I have a problem, and maybe I am overlooking something here... What I need to do, is attach multiple functions, to an Event for a particular Component. Using inline MXML, this is easy - you just separate out each function, with a semi-colon and list them one after another. BUT, I am trying NOT to put my functions within the MXML - I am using Code-Behind, and I need to add my Event Listeners within the ActionScript - using the Object.addEventListener() method. Thing is, how do I add several functions using this type of methodology? Or can it even be done? Thanks in advance for any help you can offer regarding this, Mike -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Teoti Graphix http://www.teotigraphix.com Blog - Flex2Components http://www.flex2components.com You can find more by solving the problem then by 'asking the question'.
Re: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML
Mike, Looks like you're speaking from personal experience :) From now on I'll make my custom components dispatch click and cilck and cllck and clik etc etc. The google suggest approach to event dispatching. Doug Michael Schmalle wrote: could be renamed in a future release to something like mouseClick and then your code wouldn't work. Or even worse, you write cllck, and then for days even months, you think your app isn't working or 'works' a certain way. Come to find out the event wasn't even getting captured. :) This is plain ole preventative maintainence. That is the worse case for me, renaming events is small potatoes to that error. ;-) Peace, Mike On 2/7/07, * Doug McCune* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Nope, I think the second parameter must be a function, trying to pass an array of functions should fail. Also, just a note: it's better practice to not use the string of the event listener like click but rather the variable like MouseEvent.CLICK. They really do the exact same thing in practice, but it's possible that within MouseEvent the click event could be renamed in a future release to something like mouseClick and then your code wouldn't work. Doug Mike Anderson wrote: Hey Doug, Well, that's simple enough. Probably so simple, that I simply overlooked doing it that way. Real quick, would it be possible to also do it this way? Object.addEventListener( click, [funct1, funct2, funct3] ); I know I could just try it, but from a methodology point of view, it would be nice to know if this was a valid way to do it. Thanks! Mike -Original Message- From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com] On Behalf Of dougmccune Sent: Wednesday, February 07, 2007 10:10 AM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Object.addEventListener vs.. adding them inline via MXML You can make as many calls to addEventListener as you want. So you can add 2 or more event listeners that get triggered for the same event. So something like: myButton.addEventListener(MouseEvent.CLICK, myFunction1); myButton.addEventListener(MouseEvent.CLICK, myFunction2); myButton.addEventListener(MouseEvent.CLICK, myFunction3); All three of the above functions would get called when the event triggers. You can remove each of these separately as well by using removeEventListener and specifying the particular function you want removed. Doug --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com, Mike Anderson [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hello All, I have a problem, and maybe I am overlooking something here... What I need to do, is attach multiple functions, to an Event for a particular Component. Using inline MXML, this is easy - you just separate out each function, with a semi-colon and list them one after another. BUT, I am trying NOT to put my functions within the MXML - I am using Code-Behind, and I need to add my Event Listeners within the ActionScript - using the Object.addEventListener() method. Thing is, how do I add several functions using this type of methodology? Or can it even be done? Thanks in advance for any help you can offer regarding this, Mike -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Teoti Graphix http://www.teotigraphix.com http://www.teotigraphix.com Blog - Flex2Components http://www.flex2components.com http://www.flex2components.com You can find more by solving the problem then by 'asking the question'.