单击按钮本身后,我试图使按钮消失,以显示在其下方分层的图像。它可以产生任何效果,我只需要它变得透明或离开屏幕。帮助
答案 0 :(得分: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;
}