//rotation code//
//_root:根目錄,把層級路徑指回。
//onEnterFrame:當影片被裝載時,反覆執行下面程式。
//function():自訂新的函數,主要用於繁雜的運算式,以方便在程式中可反覆使用。
//==:判斷是否相等,若相等為真則傳回ture值,否則傳回false值。
//=:把右邊的運算式指定給左邊的變數。
//-:減法運算符號。
//+:加法運算符號。
//*:乘法運算符號。
//"/":除法運算符號。
//Math.atan2:取得反正切值求得座標角度。
//_rotation:調整、取得影片的旋轉角度。
//Math.PI:取得圓周率的值。
//Math.round:取得四捨五入值。
//Math.ceil:取得最大整數值。
//********************************************************************************//

//利用根目錄設定一組新的函數,使影片開始被裝載時,反覆執行下面程式。
_root.onEnterFrame = function() {

//如果按下去的時候。
if (myPress == true) {

//將反正切值求得座標角度(y,x)回傳給myRadians。
myRadians = Math.atan2((_root._ymouse-dial._y), (_root._xmouse-dial._x));

//取得圓周率並四捨五入值回傳給myDegrees(圓周率=圓周長÷直徑長)。
myDegrees = Math.round(myRadians*180/Math.PI);

//myDegrees+90(此為控制物體旋轉角度同時也關係著dail與物體的關係)將此值回傳給dial._rotation告知它。
dial._rotation = myDegrees+90;

//利用Math.ceil取得最大整數值回傳給n,n只是一個代號,這是控制所有head裏的片段。
n = Math.ceil(((myDegrees+180)/6));
head.gotoAndStop(n);
}
}

//**************************************************************************//
//*****button code*****//

_root.dial.dialButton.onPress = function() {
myPress = true;
}
_root.dial.dialButton.onRelease = function() {
myPress = false;
}
_root.dial.dialButton.onReleaseOutside = function() {
myPress = false;
}




_root.onEnterFrame = function() {
if (myPress == true) {
myRadians = Math.atan2((_root._ymouse-dial._y),(_root._xmouse-dial._x));

myDegrees = Math.round(myRadians*180/Math.PI);
dial._rotation = myDegrees+90;
n = Math.ceil(((myDegrees+180)/6));
head.gotoAndStop(n);
}
}

_root.dial.dialButton.onPress = function() {
myPress = true;
}
_root.dial.dialButton.onRelease = function() {
myPress = false;
}
_root.dial.dialButton.onReleaseOutside = function() {
myPress = false;
}
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 catoi 的頭像
    catoi

    catoi

    catoi 發表在 痞客邦 留言(1) 人氣()