在actionscript3延迟一段时间后显示按钮
问题描述:
我一直在使用actionscript 3.0,并有一个数组给我一些文本和每个新页面上的按钮(点击按钮让我到下一个文本页面和按钮) 。我现在想让我的按钮不会立即出现在每个页面上,但时间推迟了,可能要等待10秒左右才会出现。有没有人有一个想法,我可以做到这一点?在actionscript3延迟一段时间后显示按钮
答
当你进入(creationComplete
或类似)你的“页面”按钮的alpha设置为0,则揭开序幕,设置按钮阿尔法1
答
所以我跟别人一个回调函数flash.utils.Timer
,和你也可以用actionscript写这样的:
/* Define a Timer and how long it runs, here 5 sec */
stop();
var timer1:Timer = new Timer(5000);
timer1.addEventListener(TimerEvent.TIMER, hideButtonTimer1);
/* Define the button going to the next frame on mouseclick */
btn_name.addEventListener(MouseEvent.CLICK, next);
function next(event:MouseEvent) {
play();
}
/* Hide the button on start of the timer */
btn_name.visible = false;
timer1.start();
/* turn the button visible when the timer stops */
function hideButtonTimer1(e:Event)
{timer1.stop();
btn_name.visible = !btn_name.visible;
}
你也应该在定时器回调中设置按钮的回调。否则,您可能会让用户在您想要之前单击该按钮。 – tedw4rd 2010-07-01 15:00:41
@ tedw4rd:好的呼叫......永远不能相信这些用户。 :) – sdolan 2010-07-01 17:58:42