Hi Everyone…
I have a simple sound control panel that changes the tune, starts/stops at a cue point, adjusts volume.
The action I’m getting is that the change tune function works, but on pause/play, the cue point starts from the old tune’s cue point, therefore there’s a big forward jump when play starts again. I’m trying to reset sound position and therefore var cue when I do that.
I am missing something here, so would appreciate some insights from the group. You can see it at www.sleepingdeer.com/web2/ (lower right)
Buttons are named playMusic, stopMusic, newMusic
var arrayIndex = 0; // array index initialized to first element of the array
musicArray = new Array //musicArray loaded with available tunes and paths (progressive download)
var cue = 0;
/////////////// look up duration of sound file on load success
var newBgSound:Sound = new Sound();
// determine which sound file to play according to initial the array index = 0
newBgSound.loadSound(musicArray[arrayIndex], true);
// stopMusic button
this.musicControls.stopMusic.onRelease = function() {
_root.newBgSound.stop();
cue = Math.round(newBgSound.position/1000);
// stores the position in seconds of the sound play head
};
// payMusic button
this.musicControls.playMusic.onRelease = function() {
_root.newBgSound.start(cue,3);
};
// newMusic button
this.musicControls.newMusic.onRelease = function() {
if (arrayIndex == musicArray.length-1) {
arrayIndex = 0;
}else{
arrayIndex++;
}
if (newBgSound.position > 0) {
} // try to reset sound position
newBgSound.loadSound(musicArray[arrayIndex], true);
_root.newBgSound.start(0,3);
newBgSound.position = 0;
cue = Math.round(newBgSound.position/1000);
};