onPress, onRelease, onRollOver, OnRollOut, etc. in Actionscript 3

When Actionscript 2 came out, I stopped using buttons and the old Actionscript 1 on(release) methods and starting creating movie clips for my buttons and using instanceName.onRelease functions to make buttons out of those movie clips.

Now with AS3 there is a new way to perform these functions. It’s not much harder than the old way, just different. Here are some examples:

onPress
buttonInstance.addEventListener(MouseEvent.MOUSE_DOWN,function():void {
trace(”down”);
}
);

onRelease
buttonInstance.addEventListener(MouseEvent.MOUSE_UP,function():void {
trace(”up”);
}
);

onRollOver
buttonInstance.addEventListener(MouseEvent.MOUSE_OVER,function():void {
trace(”over”);
}
);

onRollOut
buttonInstance.addEventListener(MouseEvent.MOUSE_OUT,function():void {
trace(”out”);
}
);

Pretty simple right? Not too bad at all.

Click here for some examples of other mouse actions you can track.