Problema con swf incrustado en otro
3 seguidores
Hola a tod@s.
Primer mensaje y de antemano os pido disculpas porque no soy muy experto con flash.
Incrusto en mi película un pequeño reproductor de mp3 mediante loadMovie, el swf del reproductor funciona perfectamente cuando lo lanzo solo, pero en la película principal no carga más que la primera canción y los botones de canción siguiente o anterior no funcionan, ni carga las canciones siguientes...
Alguien tiene alguna idea de cual puede ser la causa?
Gracias de antemano.
capisergio
Seguramente el reproductor tenga las llamadas a funciones con rutas absolutas. ¿Lo has programado tú o dispones del código fuente?
senseless
No lo he programado yo
Es un componente bajado de la red. En principio debería bastar con editar el archivo xml y cargar en la carpeta los mp3 nuevos. Eso funciona sin problema cuando lo ejecuto sólo, pero no cuando incrusto el swf en otro.
Este es el código:
<code>//feel free to use this MP3 player as you wish
//if you like it, or even if you don't, drop by my blog and hopefully get a little inspired at:
// http://www.asiabackpacker.com/blog/
//I've tried to add tons of comments to make it really easy to understand what everything does
//if you want to make any changes, or just understand how it works
//However, the only thing you have to edit is the .XML file, and the files in the MP3's folder
//generic actions involoved in loading XML and stripping whitespace
var SongsXML:XML = new XML();
SongsXML.ignoreWhite = true;
SongsXML.onLoad = loadSongsXML;
SongsXML.load("mySongs.xml");
//create a variable to hold the Sound object
var MP3ToPlay:Sound = new Sound();
//create a variable to hold the number of the song that is playing
var songNum:Number = 0;
//creates an array that holds the entire list of songs contained in the XML file
var songs_lst:Array = new Array();
//function to load the XML file that contains the Songs
//"success" is passed into this function to determine if and when the Function executes
function loadSongsXML(success):Void {
//if "success" gets passed here, that means the loadSongsXML function executed, so the following code will execute
if (success) { accessSongs(); }
}
function accessSongs(){
//set FolderNode variable equal to first ChildNode
//What the f does this mean? Well, it is setting up a variable called FolderNode, to hold the XML Node
//called "Folder," (in this case, the artist name)
//it is then locating this object in the XML document and setting it as the value of this variable
var FolderNode:XMLNode = SongsXML.firstChild.childNodes[0];
//Cycle through FolderNode, and add each item to songs_lst variable
//songs_lst was initialized above as an array. This for statement populates that array
for (var j:Number = 0 ; j <FolderNode> 0){
field.songName.text = "";
field.songName.text += MP3ToPlay.id3.songname;
}
}
}
//loads a sounds into the var MP3ToPlay that was created above.
//The song is loaded from the string created above in "selected song"
//The "false" refers to the streaming parameter
MP3ToPlay.loadSound(SelectedSong, false);
}
stop();</code>
Y este el código que hay en el botón "canción anterior":
<code>on (release){
_root.songNum = _root.songNum - 1;
if(_root.songNum == -1){
_root.songNum = _root.numberOfSongs-1;
}
_root.accessSongs();
playStop.gotoAndStop("stop");
}
</code>Gracias por tu ayuda capisergio
senseless
Yo mismo me voy contestando.
Algo hay de lo que comentabas. He cambiado los "_root" de la programación de los botones por "this" y funciona bien, salvo por dos cosas que si funcionan al ejecutarlo solo:
el botón play/stop hace stop, pero luego no hace play
cuando se llega a la última canción, al darle a canción siguiente no vuelve a la primera...
a ver si poco a poco...
Ventd'Aval
prueba cambiando esta linea:
var MP3ToPlay:Sound = new Sound(this);
y luego revisa el codigo que haya en el boton play/stop.... usa trace! ;)
senseless
He cambiado la línea y de lujo... !mil gracias!
Pero sigue sin pasar a la siguiente canción automáticamente se queda "empanao" cargando la canción siguiente, y el botón play/stop, sólo funciona el stop...
Usaría trace... si supiera cómo hacerlo. Es lo jodido de ser autodidacta...
Gracias por la ayuda chicos.
senseless
Sigo sin solucionar el tema del botón play/sop ni el paso automático de una canción a otra...
Alguien tiene alguna sugerencia.