1

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

Koops
  • 11
  • 1

2 Answers2

1

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
  • 15,444
  • 11
  • 59
  • 88
  • After the addEventListener line don't forget to call timer.start() or the countdown will never begin ;-) – Cameron Dec 19 '09 at 06:18
1

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: 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);
Community
  • 1
  • 1
Shoeless
  • 666
  • 1
  • 5
  • 20