mira ... tengo un script que me maneja un conjunto de elementos en el escenario (un player de audio)... estos no están en el interior de un mc.
la cuestión es que necesito en el escenario mas de un player y al duplicar los mc y cambiarles el nombre de instancia no funcionan las copias. (adiciono el script que implemente). ojala me pudieran direccionar para encontar la solucion , gracias.
//--------------------------------------------------------------------------
// initial variables that might be useful to change
// you can insert your values at the end of the lines
//--------------------------------------------------------------------------
// toggle for which file to play > path from the swfplayer
if(_root.file) { var file:String = _root.file; } else { var file:String = "producciones_M/01-Johnier-LoestasPagandoft Eloy.mp3"; }
// toggle for the downloadbutton > true or false
if(_root.showDownload) { var showDownload:String = _root.showDownload; } else { var showDownload:String = "true"; }
// toggle for autostarting the mp3 > true or false
if(_root.autoStart) { var autoStart:String = _root.autoStart; } else { var autoStart:String = "false"; }
//toggle for repeating the mp3 > true or false
if(_root.repeatPlay) { var repeatPlay:String = _root.repeatPlay; } else { var repeatPlay:String = "false"; }
// toggle for the volume of the song > 0 to 100
if(_root.songVolume) { var songVolume:Number = int(_root.songVolume); } else { var songVolume:Number = 90; }
// toggle for the backgroundcolor of the player > hex code
if(_root.backColor) { var backColor:String = "0x"+_root.backColor; } else { var backColor:String = "0xeeeeee"; }
// toggle for the backgroundcolor of the player > hex code
if(_root.frontColor) { var frontColor:String = "0x"+_root.frontColor; } else { var frontColor:String = "0x333333"; }
// toggle for the width of the mp3player > Stage.width or a number
var w:Number = 149;
//--------------------------------------------------------------------------
// functionality for playing the song
//--------------------------------------------------------------------------
var sndObject:Sound = new Sound();
var pausePos:Number = 0;
// interval ID's
var loadProgressInt:Number = new Number();
var playProgressInt:Number = new Number();
var scrubProgressInt:Number = new Number();
// loadProgress display function
function loadProgress() {
var pct:Number = sndObject.getBytesLoaded() / sndObject.getBytesTotal();
percentBar._width = pct * barWidth;
if(pct == 1) { clearInterval(loadProgressInt); }
}
// playprogress display function
function playProgress() {
var pct:Number = sndObject.position / sndObject.duration * sndObject.getBytesLoaded() / sndObject.getBytesTotal();
progressBar._width = pct * barWidth;
}
// scrub display function
function scrubProgress() {
var mouseX:Number = percentBar._xmouse * percentBar._xscale / 100;
if (mouseX > percentBar._width) { mouseX = percentBar._width; }
progressBar._width = mouseX;
var pct:Number = mouseX / barWidth;
pausePos = pct * sndObject.duration/1000;
}
// (re)start playing the song
function playSong() {
if(pausePos == 0) {
sndObject.setVolume(songVolume);
sndObject.loadSound(file,true);
loadProgressInt = setInterval(loadProgress,50);
}
sndObject.start(pausePos);
playProgressInt = setInterval(playProgress,50);
pauseBut._visible = true;
playBut._visible = false;
};
// pause the song
function pauseSong(p:Number) {
if(!p) { pausePos = sndObject.position/1000; } else { pausePos = p; }
sndObject.stop();
pauseBut._visible = false;
playBut._visible = true;
clearInterval(playProgressInt);
};
//--------------------------------------------------------------------------
// play, pause and scrubber buttons and onsoundcomplete
//--------------------------------------------------------------------------
// pause button action
pauseBut.onPress = function() {
pauseSong();
};
// play button action
playBut.onPress = function() {
playSong();
};
// start playhead scrubbing
percentBar.onPress = function() {
pauseSong();
scrubProgressInt = setInterval(scrubProgress,50);
};
// stop playhead scrubbing
percentBar.onRelease = percentBar.onReleaseOutside = function () {
clearInterval(scrubProgressInt);
playSong();
};
sndObject.onSoundComplete = function() {
if(repeatPlay == "true") {
pausePos = 0.001;
playSong();
} else {
progressBar._width = 0.1;
pauseSong(0.001);
}
}
//--------------------------------------------------------------------------
// file download functionality
//--------------------------------------------------------------------------
import flash.net.FileReference;
var listener:Object = new Object();
listener.onSelect = function(file:FileReference):Void {
trace("onSelect: " + file.name);
}
listener.onCancel = function(file:FileReference):Void {
trace("onCancel");
}
listener.onOpen = function(file:FileReference):Void {
trace("onOpen: " + file.name);
}
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}
listener.onComplete = function(file:FileReference):Void {
trace("onComplete: " + file.name);
}
listener.onIOError = function(file:FileReference):Void {
trace("onIOError: " + file.name);
}
var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
//--------------------------------------------------------------------------
// color, resize and position all items
//--------------------------------------------------------------------------
// set all backcolors
var leftBgColor:Color = new Color(leftBg);
var centerBgColor:Color = new Color(centerBg);
var rightBgColor:Color = new Color(rightBg);
leftBgColor.setRGB(int(backColor));
centerBgColor.setRGB(int(backColor));
rightBgColor.setRGB(int(backColor));
// set all frontcolors
var playButColor:Color = new Color(playBut);
var pauseButColor:Color = new Color(pauseBut);
var percentBarColor:Color = new Color(percentBar);
var progressBarColor:Color = new Color(progressBar);
playButColor.setRGB(int(frontColor));
pauseButColor.setRGB(int(frontColor));
percentBarColor.setRGB(int(frontColor));
progressBarColor.setRGB(int(frontColor));
// resize the background
leftBg._x = leftGlow._x = 200;
centerBg._x = centerGlow._x = 207;
centerBg._width = centerGlow._width = w-225;
rightBg._x = rightGlow._x = 343;
// reposition the buttons
playBut._x = pauseBut._x = 212;
percentBar._x = progressBar._x = 225;
if(showDownload == "true") {
var barWidth:Number = percentBar._width = progressBar._width =100;
} else {
var barWidth:Number = percentBar._width = progressBar._width = 32;
}
// hide unused buttons
percentBar._alpha = 50;
pauseBut._visible = false;
progressBar._width = percentBar._width = 0;
if (w <= 60) { percentBar._visible = progressBar._visible = false; }
//--------------------------------------------------------------------------
// all done ? start the movie !
//--------------------------------------------------------------------------
// start playing the movie on autoStart
if (autoStart == "true") { playSong(); }
/// script player 2-----------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------
// initial variables that might be useful to change
// you can insert your values at the end of the lines
//--------------------------------------------------------------------------
// toggle for which file to play > path from the swfplayer
if(_root.file) { var file:String = _root.file; } else { var file:String = "producciones_M/01-Johnier-LoestasPagandoft Eloy.mp3"; }
// toggle for the downloadbutton > true or false
if(_root.showDownload) { var showDownload:String = _root.showDownload; } else { var showDownload:String = "true"; }
// toggle for autostarting the mp3 > true or false
if(_root.autoStart) { var autoStart:String = _root.autoStart; } else { var autoStart:String = "false"; }
//toggle for repeating the mp3 > true or false
if(_root.repeatPlay) { var repeatPlay:String = _root.repeatPlay; } else { var repeatPlay:String = "false"; }
// toggle for the volume of the song > 0 to 100
if(_root.songVolume) { var songVolume:Number = int(_root.songVolume); } else { var songVolume:Number = 90; }
// toggle for the backgroundcolor of the player > hex code
if(_root.backColor) { var backColor:String = "0x"+_root.backColor; } else { var backColor:String = "0xeeeeee"; }
// toggle for the backgroundcolor of the player > hex code
if(_root.frontColor) { var frontColor:String = "0x"+_root.frontColor; } else { var frontColor:String = "0x333333"; }
// toggle for the width of the mp3player > Stage.width or a number
var w:Number = 149;
//--------------------------------------------------------------------------
// functionality for playing the song
//--------------------------------------------------------------------------
var sndObject:Sound = new Sound();
var pausePos:Number = 0;
// interval ID's
var loadProgressInt:Number = new Number();
var playProgressInt:Number = new Number();
var scrubProgressInt:Number = new Number();
// loadProgress display function
function loadProgress() {
var pct:Number = sndObject.getBytesLoaded() / sndObject.getBytesTotal();
percentBar._width = pct * barWidth;
if(pct == 1) { clearInterval(loadProgressInt); }
}
// playprogress display function
function playProgress() {
var pct:Number = sndObject.position / sndObject.duration * sndObject.getBytesLoaded() / sndObject.getBytesTotal();
progressBar._width = pct * barWidth;
}
// scrub display function
function scrubProgress() {
var mouseX:Number = percentBar._xmouse * percentBar._xscale / 100;
if (mouseX > percentBar._width) { mouseX = percentBar._width; }
progressBar._width = mouseX;
var pct:Number = mouseX / barWidth;
pausePos = pct * sndObject.duration/1000;
}
// (re)start playing the song
function playSong() {
if(pausePos == 0) {
sndObject.setVolume(songVolume);
sndObject.loadSound(file,true);
loadProgressInt = setInterval(loadProgress,50);
}
sndObject.start(pausePos);
playProgressInt = setInterval(playProgress,50);
pauseBut._visible = true;
playBut._visible = false;
};
// pause the song
function pauseSong(p:Number) {
if(!p) { pausePos = sndObject.position/1000; } else { pausePos = p; }
sndObject.stop();
pauseBut._visible = false;
playBut._visible = true;
clearInterval(playProgressInt);
};
//--------------------------------------------------------------------------
// play, pause and scrubber buttons and onsoundcomplete
//--------------------------------------------------------------------------
// pause button action
pauseBut.onPress = function() {
pauseSong();
};
// play button action
playBut.onPress = function() {
playSong();
};
// start playhead scrubbing
percentBar.onPress = function() {
pauseSong();
scrubProgressInt = setInterval(scrubProgress,50);
};
// stop playhead scrubbing
percentBar.onRelease = percentBar.onReleaseOutside = function () {
clearInterval(scrubProgressInt);
playSong();
};
sndObject.onSoundComplete = function() {
if(repeatPlay == "true") {
pausePos = 0.001;
playSong();
} else {
progressBar._width = 0.1;
pauseSong(0.001);
}
}
//--------------------------------------------------------------------------
// file download functionality
//--------------------------------------------------------------------------
var listener:Object = new Object();
listener.onSelect = function(file:FileReference):Void {
trace("onSelect: " + file.name);
}
listener.onCancel = function(file:FileReference):Void {
trace("onCancel");
}
listener.onOpen = function(file:FileReference):Void {
trace("onOpen: " + file.name);
}
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}
listener.onComplete = function(file:FileReference):Void {
trace("onComplete: " + file.name);
}
listener.onIOError = function(file:FileReference):Void {
trace("onIOError: " + file.name);
}
var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
//--------------------------------------------------------------------------
// color, resize and position all items
//--------------------------------------------------------------------------
// set all backcolors
var leftBgColor:Color = new Color(leftBg);
var centerBgColor:Color = new Color(centerBg);
var rightBgColor:Color = new Color(rightBg);
leftBgColor.setRGB(int(backColor));
centerBgColor.setRGB(int(backColor));
rightBgColor.setRGB(int(backColor));
// set all frontcolors
var playButColor:Color = new Color(playBut2);
var pauseButColor:Color = new Color(pauseBut2);
var percentBarColor:Color = new Color(percentBar2);
var progressBarColor:Color = new Color(progressBar2);
playButColor2.setRGB(int(frontColor));
pauseButColor2.setRGB(int(frontColor));
percentBarColor2.setRGB(int(frontColor));
progressBarColor2.setRGB(int(frontColor));
// resize the background
leftBg2._x = leftGlow._x = 200;
centerBg2._x = centerGlow._x = 207;
centerBg2._width = centerGlow._width = w-225;
rightBg2._x = rightGlow._x = 343;
// reposition the buttons
playBut2._x = pauseBut2._x = 212;
percentBar2._x = progressBar2._x = 225;
if(showDownload == "true") {
var barWidth:Number = percentBar2._width = progressBar2._width =100;
} else {
var barWidth:Number = percentBar2._width = progressBar2._width = 32;
}
// hide unused buttons
percentBar2._alpha = 50;
pauseBut2._visible = false;
progressBar2._width = percentBar2._width = 0;
if (w <= 60) { percentBar2._visible = progressBar2._visible = false; }
//--------------------------------------------------------------------------
// all done ? start the movie !
//--------------------------------------------------------------------------
// start playing the movie on autoStart
if (autoStart == "true") { playSong2(); }
