-
Play/Pause and Stop buttons
I can do this in AS2 but am struggling in 3. I've got the Play/Pause working and toggling and the Stop button stopping but I can't get the Play/Pause to toggle when the Stop button is pushed.
Here's my code:
var isPlaying:Boolean;
var soundChannel:SoundChannel = new SoundChannel();
var sound:Sound = new Sound(new URLRequest("commercial.mp3"));
xstop.addEventListener(MouseEvent.CLICK, clickStop);
xplay.addEventListener(MouseEvent.CLICK, clickPlayPause);
soundChannel = sound.play();
isPlaying = false;
soundChannel.stop();
function clickPlayPause(evt:MouseEvent) {
if (isPlaying) {
pausePoint = soundChannel.position;
soundChannel.stop();
isPlaying = false;
} else if (!isPlaying) {
soundChannel = sound.play(pausePoint);
isPlaying = true;
}
}
function clickStop(evt:MouseEvent) {
if (isPlaying) {
soundChannel.stop();
isPlaying = false;
}
pausePoint = 0.00;
}
var pp:Boolean = true;
function ppState(event:MouseEvent) {
if(pp) {
stop();
event.target.gotoAndStop('pause');
pp = false;
}else{
play();
event.target.gotoAndStop('play');
pp = true;
}
}
xplay.addEventListener(MouseEvent.CLICK, ppState);
Help?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|