View Full Version : XML and gallery... another Question?
daze13
August 4th, 2005, 04:24 PM
Hi ever1.
I have been playing with the xml gallery
http://www.kirupa.com/developer/mx2004/xml_flash_photogallery.htm
what I want to do is add sound to each slide/picture that loads..
currently my XML looks something like this
<images>
<pic>
<image>myimages.jpg</image>
<caption>my image caption</caption>
<audio>myaudio.mp3</audio>
</pic>
</images>
I can't get the mp3 to load and play!:huh:
I have made an empty MC called "audio_mc"
but still doesn't play the audio
I know i have to make some sort of function that will load and play the audio inside audio_mc but I can seem to wrap my hand around it...
the only way I know how to import dynamic audio is this way
sound = new Sound();
sound.loadSound( "test1.mp3", true);
sound.play();
how do I apply this method with xml?
so it works like the images in the gallery.
bandinopla
August 4th, 2005, 04:26 PM
sound = new Sound();
sound.loadSound( "test1.mp3", true);
sound.onLoad=function(success){
if(success){
this.play()
}
}
daze13
August 4th, 2005, 04:48 PM
sound = new Sound();
sound.loadSound( "test1.mp3", true);
sound.onLoad=function(success){
if(success){
this.play()
}
}
yes that will work but not with the XML.
this is how the image is pulled from the xml
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
audio = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
//This is the location of the image
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
//I'm assuming i have to do a similar task with the audio
audio [i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
this is how the image is loaded into a empty MC
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
//Here is where I need help;
audio_mc.loadmovie(audio[0], 2)
picture_num();
}
}
I'm not sure if this make s sense; since every record in my xml has
1-image
1-caption
1-audio file.
and I have 20 records with different audio files
I can't use "sound.loadSound( "test1.mp3", true);"
I would have to use sound.loadSound("audio[i]") or something like this I'm guessing?
bandinopla
August 4th, 2005, 04:59 PM
I think U shoul do this:
loadTaudio(audio[i])
loadTaudio=function(o){
o=new Sound()
...etc
}
employee #416
August 4th, 2005, 07:57 PM
put this in your first image function and the functions to play audio
sound = new Sound()
sound.loadSound(audio[0],true)
i hope that helps. :) and of course, change the 0 with the variable that you used to designate the index number for the previous and next functions.
daze13
August 5th, 2005, 08:52 AM
put this in your first image function and the functions to play audio
sound = new Sound()
sound.loadSound(audio[0],true)
i hope that helps. :) and of course, change the 0 with the variable that you used to designate the index number for the previous and next functions.
Thanks guys,
i made a function and called it when i need it work greats now
function load_sound() {
if (loaded == filesize) {
createEmptyMovieClip("sound_mc",2);
sound_mc.sound_obj = new Sound();
sound_mc.sound_obj.loadSound( sound[p], true);
sound_mc.sound_obj.play();
}
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.