I've been working with actionscript 3.0 and have an array that gives me some text and a button on each new page (clicking the button gets me to the next text-page and button). I'd now like my button to not appear on each page immediately, but time delayed, maybe wait 10 seconds or so before it appears. Does anyone have an idea how I could do that? Help would be very appreciated!
+1
A:
When you enter (creationComplete
or similar) your "page" set the button's alpha to 0 then kick off a flash.utils.Timer
with a callback function that sets the buttons alpha to 1.
sdolan
2010-06-30 20:48:31
You should also set the button's callback in the timer callback. Otherwise you might have users clicking on the button before you want them to.
tedw4rd
2010-07-01 15:00:41
@tedw4rd: Good call... never can trust those users. :)
sdolan
2010-07-01 17:58:42
A:
So I talked to someone, and you can apparently also write it in actionscript, this way:
/* 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;
}
Cee
2010-07-04 13:51:59