Flash ActionScript 3 help needed

Associate
Joined
20 May 2007
Posts
441
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
 
Give the imported movie (music player) a instance name, then change the stop button script to:

function songPause(event:Event):void {
pausePosition = song.position;
song.stop();
song = null;
isPlaying = false;
_root.INSTANCENAME.pause_btn.visible=false;
}
 
Back
Top Bottom