Hi,
I've created a 'fake' sound equalizer which acts as a sound toggle button. When the music plays the animation plays with the sound and when you click the animation it stops as does the sound.
However, i want the animation to play on ENTER_FRAME, but cant figure out how to do it :confused:
here's the code i have
toggleButton.addEventListener(MouseEvent.MOUSE_OVER, rolloverToggle);
toggleButton.addEventListener(MouseEvent.MOUSE_OUT, rolloutToggle);
toggleButton.addEventListener(MouseEvent.CLICK,toggleClick);
var song:Sound = new Sound();
var songChannel:SoundChannel = new SoundChannel();
song.load(new URLRequest("nyc.mp3"));
function rolloverToggle(event:MouseEvent) {
toggleButton.gotoAndStop(toggleButton.buttonState+" over");
}
function rolloutToggle(event:MouseEvent) {
toggleButton.gotoAndStop(toggleButton.buttonState);
}
function toggleClick(event:MouseEvent) {
if (toggleButton.buttonState == "on") {
toggleButton.buttonState = "off";
stopSong();
} else {
toggleButton.buttonState = "on";
startSong();
}
toggleButton.gotoAndStop(toggleButton.buttonState+" over");
}
function startSong(){
songChannel = song.play();
songChannel.addEventListener(Event.SOUND_COMPLETE, songCompleteHandler);
}
function stopSong() {
songChannel.stop();
}
function songCompleteHandler(event:Event) {
toggleButton.buttonState = "off";
toggleButton.gotoAndStop(toggleButton.buttonState+" off");
}
any help would be appreciated :)