Hey guys
Ive got a bit of a problem, I'm trying to make a website in flash, I had hoped to add a simple little music player.
Now the music player works, but when ever a button is pressed it restarts the entire movie, the player is stored as a seperate movie clip on the main stage.
the link is www.gauntface.co.uk and the actionscript is below for the music player
** NOTE : The stop button hasn't been added to work yet!! **
import flash.media.SoundTransform;
var sound:sunshine = new sunshine();
var song:SoundChannel = new SoundChannel();
var pausePosition:int = 0;
song.addEventListener(Event.SOUND_COMPLETE, songFinished);
song = sound.play();
var isPlaying:Boolean=true;
this.play_btn.visible=true;
this.pause_btn.visible=true;
this.play_btn.addEventListener(MouseEvent.CLICK, songPlay);
this.pause_btn.addEventListener(MouseEvent.CLICK,songPause);
function songFinished(event:Event):void {
this.pause_btn.visible=false;
}
function songStop(event:Event):void {
song.stop();
this.pause_btn.visible = false;
isPlaying = false;
}
function songPlay(event:Event):void {
if(isPlaying == false)
{
song = sound.play(pausePosition);
this.pause_btn.visible = true;
isPlaying = true;
}
}
function songPause(event:Event):void {
pausePosition = song.position;
song.stop();
song = null;
isPlaying = false;
this.pause_btn.visible=false;
}
Any ideas?? Any help at all would be great
Gaunt
Ive got a bit of a problem, I'm trying to make a website in flash, I had hoped to add a simple little music player.
Now the music player works, but when ever a button is pressed it restarts the entire movie, the player is stored as a seperate movie clip on the main stage.
the link is www.gauntface.co.uk and the actionscript is below for the music player
** NOTE : The stop button hasn't been added to work yet!! **
import flash.media.SoundTransform;
var sound:sunshine = new sunshine();
var song:SoundChannel = new SoundChannel();
var pausePosition:int = 0;
song.addEventListener(Event.SOUND_COMPLETE, songFinished);
song = sound.play();
var isPlaying:Boolean=true;
this.play_btn.visible=true;
this.pause_btn.visible=true;
this.play_btn.addEventListener(MouseEvent.CLICK, songPlay);
this.pause_btn.addEventListener(MouseEvent.CLICK,songPause);
function songFinished(event:Event):void {
this.pause_btn.visible=false;
}
function songStop(event:Event):void {
song.stop();
this.pause_btn.visible = false;
isPlaying = false;
}
function songPlay(event:Event):void {
if(isPlaying == false)
{
song = sound.play(pausePosition);
this.pause_btn.visible = true;
isPlaying = true;
}
}
function songPause(event:Event):void {
pausePosition = song.position;
song.stop();
song = null;
isPlaying = false;
this.pause_btn.visible=false;
}
Any ideas?? Any help at all would be great
Gaunt