2014-09-27 72 views
0

我正在使用ActionScript 2.0腳本在Flash上​​做些什麼。我有一個名爲的剪輯片段。裏面我有另一個影片剪輯名爲首發。在首發我有三個不同的按鈕,其中都有一個懸停層。 我想要那些按鈕來做什麼:當我將鼠標懸停在每個按鈕上時,我想讓它們成爲visible = false。然後當我徘徊回到正常狀態時。ActionScript 2.0 - 按鈕懸停可見false其他兩個按鈕

這些按鈕被命名爲btn1,btn2,btn3。

預先感謝您!

回答

1

恐怕我不熟悉Actionscript 2.但是,通過一點研究,我就能夠破譯這種奇怪的語言,並提出這個問題。

將它放入包含clip的圖層的操作面板中。我們今天不會將任何代碼放在對象上!

clip.starters.btn1.onRollOver = hideButtons 
clip.starters.btn2.onRollOver = hideButtons 
clip.starters.btn3.onRollOver = hideButtons 
//set the onRollOver function of each button to function hideButtons() 

clip.starters.btn1.onRollOut = showButtons 
clip.starters.btn2.onRollOut = showButtons 
clip.starters.btn3.onRollOut = showButtons 
//set the onRollOut function of each button to function showButtons() 

function hideButtons() { 
    //repeat the action for all items in "starter" 
    for (var Item in clip.starters) { 
     //make all items invisible 
     clip.starters[Item]._visible = false 
    } 
    //make the caller of hideButtons() visible 
    this._visible = true 
} 

function showButtons() { 
    //repeat the action for all items in "starter" 
    for (var Item in clip.starters) { 
     //make everything visible 
     clip.starters[Item]._visible = true 
    } 
} 

希望能爲你工作。如果你想要我的建議,學習ActionScript 3.0!它使用得更廣泛,代碼更簡潔。

祝你好運!

1

試試這個(動作2):

var Bt:Array = [_root.clip.starters.btn1, _root.clip.starters.btn2, _root.clip.starters.btn3]; 

for(i=0; i<Bt.length; i++){ 
    Bt[i].iv = i; 
    Bt[i].onRollOver = function(){ 
     for(i=0; i<Bt.length; i++){ Bt[i]._visible = false; } 
     Bt[this.iv]._visible = true; 
    }; 

    Bt[i].onRollOut = function(){ 
     for(i=0; i<Bt.length; i++){ Bt[i]._visible = true; } 
    }; 
}; 

動畫:

import mx.transitions.Tween; 
import mx.transitions.easing.*; 
var Bt:Array = [_root.clip.starters.btn1, _root.clip.starters.btn2, _root.clip.starters.btn3]; 

for(i=0;i<Bt.length;i++){ 
    Bt[i].iv = i; 
    Bt[i].onRollOver=function(){ 
     for(i=0;i<Bt.length;i++){ 
      if(i != this.iv){ 
      new Tween(Bt[i], "_alpha", Strong.easeOut, 100, 0, 15, false); 
      new Tween(Bt[i], "_x", Back.easeOut, Bt[i]._x, (Bt[i]._x-10), 1, true); 
      } 
     } 
    }; 

    Bt[i].onRollOut=function(){ 
     for(i=0;i<Bt.length;i++){ 
      if(Bt[i]._alpha ==0){ 
      new Tween(Bt[i], "_alpha", Strong.easeOut, 0, 100, 15, false); 
      new Tween(Bt[i], "_x", Back.easeOut, Bt[i]._x, (Bt[i]._x+10), 1, true); 
      } 
     } 
    }; 
};