So, I have two complex buttons next to each other, one named ‘window’ and the next named ‘window2’. On rollover of ‘window’, I wish to have the sound file ‘borat’ play, and on rollover of ‘window2’, I wish to have the sound file ‘deerhoof’ play. The sound files are placed on a layer within their respective movie clip.
When I roll over ‘window’, the button scales properly, but no sounds play. When I roll over ‘window2’, both sounds play simultaneously, which I don’t want. This is basically taking the gotoAndPlay.com Flash Math 2 tutorial, so the sounds should fade in and out based on the cursor’s proximity to the complex buttons.
I know it’s probably something stupid and simple, could somebody please take a look at my actionscript and maybe help me out?
Thanks
this.window.onRollOver = function() {
window.gotoAndPlay("_over")
}
this.window.onRollOut = function() {
window.gotoAndPlay("_out")
}
this.window2.onRollOver = function() {
window2.gotoAndPlay("_over")
}
this.window2.onRollOut = function() {
window2.gotoAndPlay("_out")
}
function proximity(clip,music) {
var x:Number = _root._xmouse;
var y:Number = _root._ymouse;
var cx:Number = clip._x;
var cy:Number = clip._y;
var prox:Number = Math.sqrt((x-cx)*(x-cx)+(y-cy)*(y-cy));
if (prox<100) {
music.setVolume(100-prox);
clip._xscale = 200 - prox;
clip._yscale = clip._xscale;
}
else {
music.setVolume(0);
clip._xscale = 100;
clip._yscale = clip._xscale;
}
}
var windowSound:Sound = new Sound(borat);
var window2Sound:Sound = new Sound(deerhoof);
this.onEnterFrame = function() {
proximity(window,windowSound);
proximity(window2,window2Sound);
}