Got a little problem. I'm building a flash mp3 player. Some how the next and previous buttons are working but sometimes the play/pause and stop buttons work occasionally. What am I doing wrong? Here is the code in AS 3.0
var playing:Boolean = false;
var pausePoint:Number = 0;
stopbutton.addEventListener(MouseEvent.CLICK, stopButtonClick);
function stopButtonClick(event:MouseEvent):void {
theChannel.stop();
pausepoint = 0;
}
playpause_button.addEventListener(MouseEvent.CLICK, playpauseButtonClick);
function playpauseButtonClick(event:MouseEvent):void {
playing = playing ? false : true;
if (playing) {
theChannel = theSound.play(pausePoint);
} else {
pausePoint = theChannel.position;
theChannel.stop();
}
}
prev_button.addEventListener(MouseEvent.CLICK, prevButtonClick);
function prevButtonClick(event:MouseEvent):void {
if (b > 1) {
b = b - 1;
theChannel.stop();
gotoAndPlay("startTrack");
} else {
b = this.totalfiles;
theChannel.stop();
gotoAndPlay("startTrack");
}
}
next_button.addEventListener(MouseEvent.CLICK, nextButtonClick);
function nextButtonClick(event:MouseEvent):void {
if (b < this.totalfiles) {
b = b + 1;
theChannel.stop();
gotoAndPlay("startTrack");
} else {
b = 1;
theChannel.stop();
gotoAndPlay("startTrack");
}
}
-
- var playing:Boolean = false;
- var pausePoint:Number = 0;
-
- stopbutton.addEventListener(MouseEvent.CLICK, stopButtonClick);
-
- function stopButtonClick(event:MouseEvent):void {
- theChannel.stop();
- pausepoint = 0;
-
-
- }
-
-
-
- playpause_button.addEventListener(MouseEvent.CLICK, playpauseButtonClick);
- function playpauseButtonClick(event:MouseEvent):void {
- playing = playing ? false : true;
- if (playing) {
-
- theChannel = theSound.play(pausePoint);
- } else {
-
- pausePoint = theChannel.position;
- theChannel.stop();
- }
- }
-
- prev_button.addEventListener(MouseEvent.CLICK, prevButtonClick);
-
- function prevButtonClick(event:MouseEvent):void {
-
- if (b > 1) {
- b = b - 1;
- theChannel.stop();
- gotoAndPlay("startTrack");
- } else {
- b = this.totalfiles;
- theChannel.stop();
- gotoAndPlay("startTrack");
- }
- }
-
-
- next_button.addEventListener(MouseEvent.CLICK, nextButtonClick);
-
- function nextButtonClick(event:MouseEvent):void {
-
- if (b < this.totalfiles) {
- b = b + 1;
- theChannel.stop();
- gotoAndPlay("startTrack");
- } else {
- b = 1;
- theChannel.stop();
- gotoAndPlay("startTrack");
- }
- }
-
-
-
Thanks in advance.