onClipEvent (load) {
x21 = this._width*0.5;
y21 = this._height*0.5;
// 取得此元件長寬的一半值用來判斷IsInside
}
onClipEvent (mouseMove) {
if (Math.abs(this._xmouse)<x21 and Math.abs(this._ymouse)<y21) {
IsInside = true;
} else {
IsInside = false;
}
}
注: x21的21代表二分之一,是我的命名習慣啦^^
若要讓程式有可讀性,應該將變數名稱變得簡單易懂
例如 x21 應該命名為 half_width
(變數命名也是很重要的喔! 尤其是teamwork的時候^^)