views:

94

answers:

2

hi there I have a flash cs4 countdown clock but I want to play a sound when timer reaches hours 0, minutes 0, seconds 0. e.g. New Years Day as target time any ideas?

p.s this is using actionscript 3

+1  A: 

hey try this

var delay:uint = calculate time that is left to newyear in milliseconds
var timer:Timer = new Timer(delay, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, newYearCallback);

function newYearCallback(e:TimerEvent):void
{
 playYourSound();
}
antpaw
After the addEventListener line don't forget to call timer.start() or the countdown will never begin ;-)
Cameron
+1  A: 

I have built a couple of different timer applications in Flash and I must tell you that Flash's timing isn't perfect... I have always encountered drift even over as short a time span as several minutes.

But if you do feel so compelled... Check the responses here: http://stackoverflow.com/questions/1425677/add-days-to-date-in-actionscript

And to play the sound, try something like:

var sound:Sound = new Sound();
sound.attachSound("mySound");
sound.start(0,0);
Shoeless