MC Events2 Decorator
Flash (in AS2) has one unpleasant habit. Interactive handlers (i.e “onRollover”, “onRollOut” , “onRelease” etc..) are being canceled as soon as you place a movie clip on the top of it with at least one interactive mouse handler defined.
Typical situation is a rollover pop up that needs to have some buttons on it. As soon as you rollOver those buttons, onRollOut event is triggered on the pop up, even though you still physically over it with your mouse.
There are of course different workarounds for this, but generally it’s a pain to code around this unfortunate behaviour.
AS3 doesn’t have this problem fortunately, but for the projects that still needs to be made in AS2 for whatever reason I created a MCEvents2Decorator class.
As it is pretty obvious from the title , it’s a decorator class, which means, it will add some new properties/handlers/events to the decorated object while keeping the old ones.
How does it works ? Pretty simple.
You call one line command : MCEvents2Decorator.decorate(mc);
this will add 3 new interactivity handlers to your movie clip :
onRelease2
onRollOver2
onRollOut2
each of them will work as you would except except they won’t be canceling other buttons functionality.
In this example try rolling over the middle button on the left and you’ll see that onRollOut even will occur on underlying button. With the decorated button this won’t happen.
Enjoy.


August 6th, 2008 at 5:36 am
Great!
We are not AS2 lovers, but this is helpful.
We will use it, if we have to do some job in AS2
August 25th, 2008 at 9:23 pm
Hi, this is a very useful classes, but I found a minor problem, when you quick rolled out the flash stage the onRollOut2 function will not execute.In your example is not clear what I’m saying, but if you have the little rectangle to a margin of the stage, it will be a problem. I had tried to solve this by myself, but the code in the class is to complex for my knowledge. If you understand me, maybe you will give some help
August 26th, 2008 at 4:43 pm
iulian,
There’s not much that can be done about this since mouse movements are evaluated every frame, so perhaps you can try increasing the framerate of your flash movie to something like 50, to force it to evaluate mouse more freqently.
The other thing I would try if I were you would be to implement updateAfterEvent…