Skip to main content
Inspiring
June 20, 2008
Answered

Streaming MP3 controls

  • June 20, 2008
  • 6 replies
  • 544 views
So the problem I'm having is the play and pause buttons work with the timeline but the audio keeps running.

I have a flash movie with a preloader in Scene 1, Scene 2 is just a standard timeline movie. I have the sound loading using this script in a MC on a layer.

mySound = new Sound();
mySound.loadSound("FullUp1.mp3", true);
mySound.start();

I'm using a movie clip with controls in Scene 2 with the play and pause buttons:
Play Btn:
on (release) {
_parent.play();
with ("Suazo") {
play;
}
}

Pse Btn:
on (release) {
_parent.stop();
with ("Suazo") {
pause;
}
}

The movie clip with the mysound code has an instance name of "Suazo." Any ideas?


This topic has been closed for replies.
Correct answer Jefe2801
Thanks for both of your help.

6 replies

kglad
Community Expert
Community Expert
June 23, 2008
you're welcome.
Jefe2801AuthorCorrect answer
Inspiring
June 23, 2008
Thanks for both of your help.
Participant
June 23, 2008
hope this helps

//variable to store song position
var pos:Number;
//put this function on your pause button press
function pauseIt():Void
{
pos = mySound.position;
mySound.stop();
}
//put this function on your unpause button press
function unPauseIt():Void
{
mySound.start(pos/1000);
}
kglad
Community Expert
Community Expert
June 23, 2008
yes. when you start() your sound you can use an offset parameter to start() at any point. you'll start at your sound's position property. (the position is in milliseconds and the offset parameter is in seconds, so divide the position by 1000.)
Jefe2801Author
Inspiring
June 23, 2008
Thanks for your help with this, I've got the voiceover to stop and start with the movie now but it doesn't resume playing from the same place, it just starts over. Is there anyway to control that?
kglad
Community Expert
Community Expert
June 20, 2008
what's Suazo and what's play and pause?

you should be using your sound instance's start() and stop() methods.
Jefe2801Author
Inspiring
June 20, 2008
I put the load sound actionscript in a movie clip and gave it an instance name of Suazo which is in scene 2. I later realized that I needed to direct it so I added "Scene 2", Suazo" but I'm pretty sure that's still completely wrong. I changed the "pause" to "stop" and play to start but it's still not operational.

Play and pause are just the names of the two buttons in the sound/timeline controller movie clip. Is there an easier way I can control the sound an timeline with one button?
kglad
Community Expert
Community Expert
June 21, 2008
use:

mySound.start(); // to play your sound

mySound.stop(); // to stop your sound

if you're executing code from a timeline OTHER than the time where mySound was instantiated, prefix mySound() with the absolute or relative path to mySound.