0
我試圖讓一個按鈕消失後,點擊按鈕本身顯示在它下面的圖層。它可以有任何影響,爲了做到這一點,我只是需要它變得透明或脫離屏幕。幫幫我?,點擊時如何讓按鈕消失?
我試圖讓一個按鈕消失後,點擊按鈕本身顯示在它下面的圖層。它可以有任何影響,爲了做到這一點,我只是需要它變得透明或脫離屏幕。幫幫我?,點擊時如何讓按鈕消失?
如果你有一個名爲「myButton的」按鈕:
//listen for mouse clicks
myButton.addEventListener(MouseEvent.CLICK, mouseHandler);
//handle mouse clicks
function mouseHandler(event:MouseEvent):void
{
//stop listening for clicks
myButton.removeEventListener(MouseEvent.CLICK, mouseHandler);
//make button invisible
myButton.visible = false;
}
這將使按鈕瞬間消失在單擊時。如果您想應用淡入淡出效果...
myButton.addEventListener(MouseEvent.CLICK, mouseHandler);
function mouseHandler(event:MouseEvent):void
{
myButton.removeEventListener(MouseEvent.CLICK, mouseHandler);
addEventListener(Event.ENTER_FRAME, fadeOut);
}
function fadeOut(event:Event):void
{
var a:Number = myButton.alpha-0.05;
if (a<=0)
{
a = 0;
removeEventListener(Event.ENTER_FRAME, fadeOut);
}
myButton.alpha = a;
}