ehaugw
530 posts
|
Hey, is there an easy way to know when any button in a SWF has been mouse-overed, without adding a listener to each button?
|
|
|
Aesica
951 posts
|
So you want to check for an event without using an event listener? Perhaps witchcraft is what you’re looking for.
|
|
|
NineFiveThree
1370 posts
|
What’s the motivation behind your request?
What are you trying to do?
You can add it in the class of your buttons.
That’d still add it to every object, but the adding is happening in “one place” code wise.
You can add the listener to the document class and let the Events bubble up.
This however does not necessarily give you access to the button object via .target, if it has mouseChildren.
|
|
|
ehaugw
530 posts
|
Originally posted by Aesica:
So you want to check for an event without using an event listener? Perhaps witchcraft is what you’re looking for.
Thanks for helping…
Originally posted by NineFiveThree:
What’s the motivation behind your request?
What are you trying to do?
You can add it in the class of your buttons.
That’d still add it to every object, but the adding is happening in “one place” code wise.
You can add the listener to the document class and let the Events bubble up.
This however does not necessarily give you access to the button object via .target, if it has mouseChildren.
I want to add a glow filter to my cursor when it is hovering over a SimpleButton clip, the .target property is not needed.
What could be possible is to overwrite the mouseover function of the SimpleButton class to tell when I have hovered the mouse over a button. What would you say about that 953?
|
|
|
Draco18s
6860 posts
|
|
|
|
NineFiveThree
1370 posts
|
|
|
|
BobTheCoolGuy
3757 posts
|
I actually wrote a short tutorial on how to use the custom cursor API back when I actually thought spending time to maintain a blog was a good idea. (I know, crazy right?)
Anyway, here’s the link, maybe it will help, maybe not.
|
|
|
player_03
1249 posts
|
I suspect getObjectsUnderPoint() is what you’re looking for.
function mouseOverButton():Boolean {
for each(var object:DisplayObject in stage.getObjectsUnderPoint(
new Point(stage.mouseX, stage.mouseY))) {
if(object is SimpleButton) {
return true;
}
}
return false;
}
|
|
|
Elyzius
235 posts
|
Originally posted by Aesica:
So you want to check for an event without using an event listener? Perhaps witchcraft is what you’re looking for.
Not too long ago, I read a blog post of an AS3 coder who said that whenever he sees events in anybody’s code, he immediately replaces them with callback functions. I haven’t seriously looked into the performance of events versus callbacks, but it’s something that I’ve been meaning to check out someday.
Originally posted by BobTheCoolGuy:
I actually wrote a short tutorial on how to use the custom cursor API back when I actually thought spending time to maintain a blog was a good idea. (I know, crazy right?)
(Elyzius hides his blog under a rug.)
Anyway, here’s the link, maybe it will help, maybe not.
Uh, Bob, I don’t think Chrome likes SWFCabin at all.

|
|
|
BobTheCoolGuy
3757 posts
|
Elyzius: Oh my. That’s quite the surprise. Well, my apologies if somehow it contains malware, although I highly doubt it does. Coincidentally, URLVoid show’s it’s clean. That being said, don’t take any risks on the internet.
|
|
|
Draco18s
6860 posts
|
Originally posted by BobTheCoolGuy:
Elyzius: Oh my. That’s quite the surprise. Well, my apologies if somehow it contains malware, although I highly doubt it does. Coincidentally, URLVoid show’s it’s clean. That being said, don’t take any risks on the internet.
FTFY ;)
|
|
|
Elyzius
235 posts
|
Well, Bob’s a cool guy. I’m sure all his SWFs are safe. The same cannot be said for some of the SWFs that have been uploaded to SWFCabin. One can code malware with Actionscript, and apparently some people have. Any repository of SWFs can potentially harbor malware. One can only hope that the people who upload their files to FastSWF have nothing but good intentions. Hopefully, user registration and a login screen can be implemented in FastSWF soon so that if anyone uploads malware, you’ll know who’s the guilty party.
|
|
|
Ace_Blue
1091 posts
|
Originally posted by Elyzius:
Not too long ago, I read a blog post of an AS3 coder who said that whenever he sees events in anybody’s code, he immediately replaces them with callback functions. I haven’t seriously looked into the performance of events versus callbacks, but it’s something that I’ve been meaning to check out someday.
Do you still have the link? I find the event system clunky, but I’ve never found a way to bypass it that didn’t also involve breaking encapsulation. I’d be very curious to see how this guy went about it.
|
|
|
Aesica
951 posts
|
^ Likewise, although I’ve found that making a self-cleaning sprite class helps tone down the clunkiness a bit. I didn’t actually know it was possible to bypass it altogether, so this is of interest.
|
|
|
Elyzius
235 posts
|
I can’t find the guy’s blog for the life of me. I never bothered to bookmark it because the author struck me as rather peculiar. Aside from replacing events with callbacks when changing someone else’s code, he also said that he deletes all comments until none are left. Surely comments have no effect on SWF performance, right?
Nevertheless, the idea of replacing events with callbacks did not seem to originate from him. The genius behind this idea is apparently Robert Penner, whom I am absolutely certain is not the same man who slaughters innocent comments without mercy. If you want to read about Signals, Penner’s alternative to AS3 events, click here.
For further reading, you may want to click this, this, and this.
|
|
|
Ace_Blue
1091 posts
|
Thank you very much, the first ‘this’ link actually explained it really well. As for scrubbing all comments on sight… well, I’m no friend of comments myself (I am of the opinion that proper code should be self-evident and that finding a good variable/function name is a better use of one’s time than writing a comment to justify or explain a bad name) but I still find that attitude extreme.
|