la variable que uso es : MovieClip(root).variable que la envio desde la pelicula principal
lo que no logro es detener ni llamar a otro mp3
Código Javascript :
stop();
// Assign The URL to the mp3 to play
var req:URLRequest = new URLRequest(MovieClip(root).variable);
// Boolean value for button functions, to switch in the conditionals
var isPlaying:Boolean = true;
// Create the sound object
var snd:Sound = new Sound(req);
// Assign a var name for the sound channel
var channel:SoundChannel;
// Pause position variable
var pausePosition:Number = 0;
// Start Playing
channel = snd.play(pausePosition);
// Make Play button change cursor to click hand
playBtn.buttonMode = true;
// Move the play/pause button movieclip to frame 2(active state)
playBtn.gotoAndStop(2);
// Play Button Listener
playBtn.addEventListener(MouseEvent.CLICK, playPause);
channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
// On playback complete function ///////////////////////////////////
function onPlaybackComplete(event:Event) {
//trace("The sound has finished playing.");
pausePosition = 0;
channel = snd.play(pausePosition);
isPlaying = true;
channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
}
// Play/Pause button function ////////////////////////////////////////
function playPause(event:MouseEvent):void {
// This conditional makes the magic of our play/pause functionality
if (isPlaying == false) {
channel = snd.play(pausePosition); // Start playing
isPlaying = true; // Set the isPlaying Boolean to true
playBtn.gotoAndStop(2); // Move the play/pause button movieclip to frame 2
channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
} else {
pausePosition = channel.position;
channel.stop(); // Stop Playing
playBtn.gotoAndStop(1); // Move the play/pause button movieclip to frame 2(paused)
isPlaying = false; // Set the isPlaying Boolean to false
}
}gracias por la atencion prestada
