Hi, I’m building an mp3 player in Flash and it will load the audio and play it but it won’t pause. Here’s my code.
onLoad(pauseIt());
// Check to see if song url is included.
// See if song url is specified
if(!song_url) {
// If not then stop movie and display frame error
playPause.gotoAndStop("error");
}else {
// Set up sound variable
var my_sound:Sound = new Sound();
// Load Audio
my_sound.loadSound(song_url, true);
// Set Volume to 100%
my_sound.setVolume(100);
// Position of Music
var pos:Number;
// ------- Pausing and unPausing functions ------- \\
// Pauses the music
function pauseIt():Void {
pos = my_sound.position;
my_sound.stop();
}
// Pauses the music
function playIt():Void {
my_sound.start(pos/1000);
}
// Play/Pause Toggle
playPause.onRollOver = function() {
if(this._currentframe == 1) this.gotoAndStop("PlayOver");
else this.gotoAndStop("PauseOver");
}
playPause.onRollOut = playPause.onReleaseOutside = function() {
if(this._currentframe == 10) this.gotoAndStop("Play");
else this.gotoAndStop("Pause");
}
playPause.onRelease = function() {
if(this._currentframe == 10) {
this.gotoAndStop("PauseOver");
pauseIt();
}else {
this.gotoAndStop("PlayOver");
playIt();
}
}
}
Thanks in advance
song_url=“song.mp3”;
btn.onRelease=function()
{
pauseIt();
}
// ------- Pausing and unPausing functions ------- \
// Pauses the music
function pauseIt():Void {
pos = my_sound.position;
my_sound.stop();
}
// Pauses the music
function playIt():Void {
my_sound.start(pos/1000);
}
//onLoad(pauseIt());
// Check to see if song url is included.
// See if song url is specified
if(!song_url) {
// If not then stop movie and display frame error
playPause.gotoAndStop(“error”);
}else {
// Set up sound variable
var my_sound:Sound = new Sound();
// Load Audio
my_sound.loadSound(song_url, true);
// Set Volume to 100%
my_sound.setVolume(100);
// Position of Music
var pos:Number;
// Play/Pause Toggle
playPause.onRollOver = function() {
if(this._currentframe == 1) this.gotoAndStop(“PlayOver”);
else this.gotoAndStop(“PauseOver”);
}
playPause.onRollOut = playPause.onReleaseOutside = function() {
if(this._currentframe == 10) this.gotoAndStop(“Play”);
else this.gotoAndStop(“Pause”);
}
playPause.onRelease = function() {
if(this._currentframe == 10) {
this.gotoAndStop(“PauseOver”);
pauseIt();
}else {
this.gotoAndStop(“PlayOver”);
playIt();
}
}
}
//------------------------------------------------
well you code seems to work just on registering the pauseit() and playit() functions in the begining lines… of the actionscript codes
just used a button called btn to test it… seems to be fine…