我試圖創建一個函數(由一個mouseover事件調用),它將在鼠標懸停在實例上時向後播放電影,並在不是時停止。While循環在ActionScript 3.0中不起作用
這是我到目前爲止有:
var b2:rightButton = new rightButton(); //new instance
b2.X = 550; //instances position
addChild(b2); //add instance to stage
b2.alpha = .4; // set instances alpha
var num = 0; // new variable called 'num'
b2.addEventListener(MouseEvent.ROLL_OVER, rightScroll); //mouse event for roll over
function rightScroll(event:MouseEvent) { //the function
num = 1; //set num to 1
b2.alpha = .8; //set alpha to 80%
}
b2.addEventListener(MouseEvent.ROLL_OUT, no_rightScroll); //event for roll out
function no_rightScroll(event:MouseEvent){ //roll- out function
num = 0; //set num back to 0
b2.alpha = .4; //set alpha back to 40%
}
while (num == 1){ // while num =1 (while mouse is over)
prevFrame(); //goto previous frame
}
有誰知道如何解決這個問題,或者更好的方式來做到這一點?
這是封裝在一個類中,還是它是一個框架腳本?如果它是一個framescript,你可能會遇到嚴重的範圍問題。 –
我沒有在這裏看到任何範圍問題,但使用任何類型的動畫循環是一個壞主意。 – shanethehat