I am trying to sync a sound effect with an action in a flash game, but it does'nt seem bo be working. I am trying to make an explsion sound when the player's ship gets destroyed, here's some of my code
mySoundObject = new Sound(); //initializing my sound
MySoundObject.attachSound("explosion.wav");
and then a bit later
createEnemy = function(type, x, y)
{
var nm = "enemy" + enemyCount;
enemyLayer.attachMovie(type, nm, enemyCount);
enemyLayer[nm]._x = x;
enemyLayer[nm].xline = x;
enemyLayer[nm]._y = y;
enemyLayer[nm].dy = Math.random() * 3 + 10;
enemyLayer[nm].t = Math.random() * 6.28;
enemyLayer[nm].onEnterFrame = function()
{
this._x = this.xline + Math.sin(this.t) * 100;
this._y += this.dy;
this.t += 0.1;
if (this._currentframe == 1 && ship.hitTest(this._x, this._y, true))
{
counter = 1;
doCounter();
ship.play();
mySoundObject.start(0,1); //place I tried to put my sound
}
if (this._y > 500) this.removeMovieClip();
}
enemyCount ++;
enemyCount %= 10;
}
I have tried a few things, but they either play the sound as soon as I start the game, or they do not play the sound at all. does anyone have any ideas?