Here's the explanations:
What the function SetPosByOrigCenter() does is: set the position by setting it to the x (and y) of the original center point minus half of the width (and height) of the object (the object here is a button)
public function SetPosByOrigCenter():void {
//this: the button
this.x = origCenterPoint().x - this.width / 2;
this.y = OrigCenterPoint().y - this.height / 2;
}
What the function SetPosByOrigCenterOnEvent() does:
public function SetPosByOrigCenterOnEvent(e:Event):void {
//e:Event is a must for event function in AS3
SetPosByOrigCenter();
}
The function SetPosByOrigCenterOnEvent() is called every time the button is transformed in size like these buttons in Frantic Frigates:
public function Button(...) {
...
this.addEventListener(MouseEvent.MOUSE_OVER, TransformSizePOnEvent);
this.addEventListener(MouseEvent.MOUSE_OVER, SetPosByOrigCenterOnEvent);
this.addEventListener(MouseEvent.MOUSE_OUT, ResetSizeOnEvent);
this.addEventListener(MouseEvent.MOUSE_OUT, SetPosByOrigCenterOnEvent);
this.addEventListener(MouseEvent.CLICK, ResetSizeOnEvent);
this.addEventListener(MouseEvent.CLICK, SetPosByOrigCenterOnEvent);
...
}
Maybe, I just rename it ResetPosition() or let it remain unchanged