Skip to main content
Participating Frequently
November 6, 2007
Question

multiple functions for a mouse event?

  • November 6, 2007
  • 4 replies
  • 446 views
I have a button class I've created in AS3 which causes a button to grow and glow during Mouse_Over.
As I have it set up, there are individual Event listeners for expand and glow.
Is there any way to combine those two functions under one event listener, so that I would just have two Event listeners and not four?
This topic has been closed for replies.

4 replies

clbeech
Inspiring
November 6, 2007
interesting kg, (i hadn't seen your post till now) also, will AS3 not let one define the filter within the constructor(eg. my method above)? this would seem to be more efficient than redefining the filter on each event.
clbeech
Inspiring
November 6, 2007
you're welcome px :) happy grinding, lol!
kglad
Community Expert
Community Expert
November 6, 2007
it would be better programming style to keep the two functions separate and call one from the other.
Participating Frequently
November 6, 2007
Here's another shot at it, where I'm having the expand function call the glowOrange function.
It seems to work. Is this more appropriate programming style?
thanks,
mike
clbeech
Inspiring
November 6, 2007
conbined the 'expand' and 'glowOn' methods, into a single method, and conbined the 'contract' and 'glowOff' into a single method as well. Then only call one method on each event, all of the code within each of the corresponding methods should function within a single method without any trouble. But additionally, if your simply removing the filter, you shouldn't need to redefine it on each call, you should only need to set it up once, then set the property to null to remove it, I think more like this:
Participating Frequently
November 6, 2007
thank you very much.
I ran into some errors with the code, but taking baby steps, I was able to shorten my code by combining the scale and glow properties into a single function.
-good to know about the "null" function. My previous workaround was just to set the alpha to 0 and omit the rest of the color info. -this is even better.
Thankfully, I'll be able to study your code and hopefully glean even more insight than I had hoped for.

thanks,
mike