Hi,
would anyone have an idea how this could best be done?
I have a sound object which should loop continuously but the speed of looping should be dependant on the speed of a moving mc on stage.
I tried something like this:
Sound.prototype.playAtInterval = function(nMillis)
{
var currentSound = this;
var nInterval = nMillis + this.duration;
var nCounter = 0;
var startTime;
var isInitialized = false;
var soundTimer_mc = _root.createEmptyMovieClip("soundTimer_mc", 1);
soundTimer_mc.onEnterFrame = function()
{
if (!isInitialized)
{
isInitialized = true;
startTime = getTimer();
}
var currentTime = getTimer();
var nDiff = currentTime - (startTime + (nCounter * nInterval));
if (nDiff > nCounter * nInterval)
{
currentSound.start();
nCounter++;
}
}
}
var mySound = new Sound();
mySound.attachSound("spinner_sound");
mySound.playAtInterval(10);
but when the interval is too small the sound doesn’t loop evenly, I guess because of the onEnterFrame.
Any other ideas?