how to avoid flikering button problem on Flash

From the earliest versions of Flash sometime we experienced this simple problem: - using MovieClips as Buttons and scaling them as rollover/rollout effect we got that ugly flickering effect.-
Today I read a very long tread about designers in serarch of some solution for this old issue. Since I didn't found an answer that satisfies me and since is really easy avoiding this problem I wrote this simple function:
function addButtonEvent(btn:DisplayObject):void {
 MovieClip(btn).buttonMode = true;
 MovieClip(btn).mouseChildren = false;
 var square:Sprite = new Sprite();;
 var p = btn.getRect(btn.parent);, p.y, p.width, p.height);
 square.visible = false;
 MovieClip(btn).hitArea = square;
 btn.addEventListener (MouseEvent.MOUSE_OVER, blinkOver);
 btn.addEventListener (MouseEvent.MOUSE_OUT, blinkOut);
function blinkOver(e:MouseEvent = null) {
 Tweener.addTween(, { scaleX:1.08, scaleY:1.08,time:.3 } );
private function blinkOut(e:MouseEvent  = null) {
 Tweener.addTween(, {scaleX:1, scaleY:1,time:.1 } );

As you can see the tip is to create a static rectangle over the MovieClip and using it as hitArea.
You just need to call the addButtonEvent function in this way:


(super simple!!!) Note that for the scaling easing I used Caurina tweener


Posta un commento