Here is the code I’ve got so far:
campFireSound_mc.onEnterFrame = function(){
xdist = Math.round(this._x-fenris_mc._x);
ydist = Math.round(this._y-fenris_mc._y);
campFireDistance = Math.round(Math.sqrt((xdist*xdist)+(ydist*ydist)));
if(campFireDistance < 150){
soundFX.start();
} else {
soundFX.stop();
}
}
The problem is the sound starts 24 times/sec because of the onEnterFrame event. Basically I want to check the distance between this movieclip and another (that the user can move w/ the arrow keys) and if its within a certain distance to start playing the sound.
Here is the SWF so you can see how it works so far:
http://www.littlefenris.com/v2/distance_testing_001.html
The idea is the user can move a character around and when the character gets close enough to certain objects, the sound effects for that object start. In this case when the character walks close enough to the fire movieclip I want them to be able to hear the fire. I just don’t know how to constantly check for distance but only start the object once so it doesn’t keep starting it w/ the onEnterFrame.
Any help is appreciated.