begin process at 2012 05 27 14:10:00
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Flash / Flash MX

 > 

Base de données

 > 

XML

 > 

Loader de XML


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Loader de XML

mercredi 23 avril 2008 à 09:31:41 | Loader de XML

Orange73

Membre Club
Hello,

Je souhaiterai savoir si quuelqu'un connait un script pour loader différents xml avec un seul load xml genre : monXML.load(uneVariable);

uneVariable sera le xml en question chargé suivant son désir dans un endroit d'un site par exemple. Une sorte donc de Queue XML


merci
mercredi 25 novembre 2009 à 22:11:21 | Re : Loader de XML

BBFUNK01

Salut Orange73,

je répond à ta question non pas par une réponse mais plutôt par une autre question : as-tu trouvé le script adéquat ? En fait j'ai un peu le même problème que toi : j'ai un player mp3 auquel j'ai ajouté un coverflow, le coverflow comprend plusieurs covers, et je cherche un script qui permettrait lorsqu'on clique sur une cover de charger une playlist en xml. Ex.: en cliquant sur la cover "rock", on charge la playlist "rock" sur le player mp3, si on clique sur la cover "reggae", on charge la playlist "reggae".
Le problème sur lequel je bute est le suivant :
le coverflow est géré par un xml, et il faudrait que dans mon code as2 je puisse indiquer lors du clic sur la cover que le fichier xml "playlist" à charger se trouve dans le fichier xml du coverflow, du genre :
Code ActionScript :
cover.onPress = function(){
myplaylist.load(infostruc[current-1].albumLink)
}


J'ai essayé aec cette méthode mais ça ne permet pas de charger le xml "playlist" indiqué dans le xml du coverflow.
Je me demande donc s'il est possible de charger un xml à partir d'un autre xml. Bref, si tu as trouvé la réponse à ta question ça peut peut-être me donner une piste pour mon script, et si jamais tu sais comment faire pour charger un xml à partir d'un autre xml je serai ravi que tu me donnes le tuyau.

Merci.

A plus,

BBFUNK01:)
mercredi 25 novembre 2009 à 22:45:14 | Re : Loader de XML

Orange73

Membre Club
Hello,

Oulala sa date ce post lol. Depuis bien des choses ont evolué niveau technique mdr.
Tu devrait passer en AS3, la gestion du XML est top.

Sinon en AS2 tu pourrai faire une fonction de loading de xml genre :

Code ActionScript :
var currentPlayList;

function loadPlaylist(pString:String)
{
    var myXML:XML = new XML();
    myXML.ignoreWhite = true;
    myXML.load(pString);
    myXML.onLoad = function(success)
    {
        if(success)
            currentPlayList = myXML.firstChild.childNodes;
    }
}


ensuite tu appel la fonction lors du clic :

Code ActionScript :
cover.onPress = function()
{
    loadPlaylist(infostruc[current-1].albumLink); // le parametre doit etre de type String et finir par ".xml"
}


A+

-- Orange73 --

"L'homme n'est pas fait pour travailler, la preuve c'est que cela le fatigue" (Voltaire)

mercredi 25 novembre 2009 à 22:48:19 | Re : Loader de XML

Orange73

Membre Club
Sinon ton exemple
Code ActionScript :
cover.onPress = function(){
    myplaylist.load(infostruc[current-1].albumLink)
}

devrait marcher aussi normalement.

Que contient
Code ActionScript :
infostruc[current-1].albumLink
exactement ?

-- Orange73 --

"L'homme n'est pas fait pour travailler, la preuve c'est que cela le fatigue" (Voltaire)

mercredi 25 novembre 2009 à 22:59:31 | Re : Loader de XML

BBFUNK01

Re Orange73,

ce que contient
Code ActionScript :
infostruc[current-1].albumLink
c'est le nom du xml à loader, ex.: "rocklist.xml", mais je ne sais pas si j'ai fais les choses correctement car en testant ça ne marche pas. J'imagines bien qu'en as3 les fonctions sont mieux, mais comme j'ai déjà du mal en AS2... ors le problème c'est que les codes du player mp3 et du coverflow ne sont pas de moi, mais sont en as2, donc pour les transposer en as3 je ne suis pas de taille.
mercredi 25 novembre 2009 à 23:02:04 | Re : Loader de XML

BBFUNK01

Voici le code de mon player mp3, à mon avis c'est sur ce code que j'ai merdé à un endroit :
Code ActionScript :
//defines a new sound object
music = new Sound(this);
trkInfo = new Date();


//comment these three lines if you don't want it to play on startup
playing = false;
paused = false;
loading = true;
///////////////////////////////////////////////////////////////////

//sets the beginning slider attributes
vol_mc.slider_mc._x = 70;
bal_mc.slider_mc._x = 50;
pos_mc.slider_mc._x = 0;
pos_mc.slider_mc._visible = false;
vol_mc.slider_mc.slider.useHandCursor = false;
bal_mc.slider_mc.slider.useHandCursor = false;
pos_mc.slider_mc.slider.useHandCursor = false;
scroller_mc.slider_mc.slider.useHandCursor = false;
loop_mc.radio_mc.useHandCursor = false;
shuffle_mc.radio_mc.useHandCursor = false;
//controls which song is highlighted in the playlist, see attacher
function select(){
	for(i in playlist_mc.target_mc){
		if(playlist_mc.target_mc[i].songNum != songNum){
			playlist_mc.target_mc[i].gotoAndStop(1);
		}
		else{
			playlist_mc.target_mc[i].gotoAndStop(2);
		}
			
	}
	
}

songNum = 0;
numTracks = songInfo.content.length;
//attacher: attaches the playlist movies, select() is called here
for(i = 0; i < numTracks; i++){
	songInfo.content[i].songNum = i;
	playlist_mc.target_mc.attachMovie("playlistItem", "item" + i, (i+1), songInfo.content[i]);
	playlist_mc.target_mc["item" + i]._y = i * 18;
	if(playlist_mc.target_mc["item" + i].title == songInfo.content[songNum].title){
		playlist_mc.target_mc["item" + i].gotoAndStop(2);
	}
	else{
		playlist_mc.target_mc["item" + i].gotoAndStop(1);
	}
}

scrollWindowHeight = 72;
scrollMax = (playlist_mc.target_mc._y + playlist_mc.target_mc._height) - scrollWindowHeight;

//if there's not enough to scroll, there will be no handle

if(playlist_mc._height <= scrollWindowHeight){
	scroller_mc.slider_mc._visible = false;
}
else{
	scroller_mc.visible = true;
}

//loads the song
music.loadSound(songInfo.content[songNum].path, false);

//this is what makes the music fade when you hit the stop button
function fadeOut() {
	if (music.getVolume()>0) {
		music.setVolume(music.getVolume()-5);
	} else {
		music.stop();
		pos_mc.slider_mc._visible = false;
		pos_mc.slider_mc._x = 0;
	}
}

//this function is called when the first song ends, or the next button is press.  It moves to the next song
function nextSong(){
		if(loop == true and skipLoop != true){
			music.stop();
			music.start(0, 0);
		}
		else{
			if(shuffle == true){
				songNum = Math.floor(Math.random()*(numTracks-1));
			}
			else{
				songNum++;
				if(songNum == songInfo.content.length){
					songNum = 0;
				}
			}
		loading = true;
		playing = false;
		paused = false;
		select();
		if(skipLoop == true){
			skipLoop = false;
		}
		music.loadSound(songInfo.content[songNum].path, false);
		}
	
		
}

//self explantory =)
function prevSong(){
	songNum--;
	if(songNum < 0){
		songNum = songInfo.content.length - 1;
	}
		
		loading = true;
		playing = false;
		paused = false;
		
		select();
		music.loadSound(songInfo.content[songNum].path, false);
	
}
//this function controls the text in the info window and what actions the player will take next based on what button is pressed
this.onEnterFrame = function() {
	dur = music.duration;
	pos = music.position;
	total = music.getBytesTotal();
	loaded = music.getBytesLoaded();
	
	//preloader
	if (loading == true) {
		if (music.getBytesLoaded() == music.getBytesTotal() and dur > 0){
			loading = false;
			playing = true;
			music.start(0,0);
			music.setVolume(vol_mc.slider_mc._x);
			music.setPan((bal_mc.slider_mc._x-50)*2);
			status = "playing";
			pos_mc.slider_mc._visible = true;
		}
		else{
			pos_mc.slider_mc._visible = false;
			
			if(music.getBytesTotal() != undefined){
				artist = Math.round(music.getBytesLoaded()/music.getBytesTotal()*100)+"% loaded";
			}
			else{
				artist = undefined;
			}
			
			title = undefined;
			status = "loading";
		}
	}
	
	//updates the sound attributes (vol, bal, etc...) and displays their info in the text fields
	else if (playing == true) {
		vol = music.getVolume() + "%";
		bal = music.getPan();
		if(whichDrag != "pos_mc"){
				pos_mc.slider_mc._x = (music.position/music.duration)*100;
		}
		
		music.setVolume(vol_mc.slider_mc._x);
		music.setPan((bal_mc.slider_mc._x-50)*2);
		titleArtist = songInfo.content[songNum].path;
		title = songInfo.content[songNum].title;
		artist = songInfo.content[songNum].artist;
		music.onSoundComplete = nextSong;
		
	} else{
		titleArtist = undefined;
		fadeOut();
		status = "stopped";
	}
	
	//controls the scrolling of the playlist
	if(scrolling == true){
		if(playlist_mc._height > scrollWindowHeight){
			percentScroll = (scroller_mc.slider_mc._y/(scroller_mc.scrollBg_mc._y + scroller_mc.scrollBg_mc._height));
			scrollValue = scrollMax*percentScroll;
			playlist_mc.target_mc._y = -(scrollValue);
		}
	}
	
	
	//displays the time
	if(timeWay == "forward" or timeWay == undefined){
		trkInfo.setSeconds(music.position/1000);
		trkInfo.setMinutes((music.position/1000)/60);
		trkInfo.setHours((music.position/1000)/3600);
	}
	else{
		trkInfo.setSeconds((music.duration -music.position)/1000);
		trkInfo.setMinutes(((music.duration -music.position)/1000)/60);
		trkInfo.setHours(((music.duration -music.position)/1000)/3600);
	}
	seconds = trkInfo.getSeconds();
	minutes = trkInfo.getMinutes();
	hours = trkInfo.getHours();

	
	if(seconds < 10){
		seconds = 0 + seconds.toString();
	}
	if(minutes < 10){
		minutes = 0 + minutes.toString();
	}
	if(hours < 10){
		hours = 0 + hours.toString();
	}
	
	trkHrs = Math.floor((music.duration/1000)/3600);
	trkMin = Math.floor((music.duration/1000)/60);
	trkSec = Math.floor((music.duration/1000) - (60*trkMin));
	if(trkSec < 10){
		trkSec = 0 + trkSec.toString();
	}
	if(trkMin < 10){
		trkMin = 0 + trkMin.toString();
	}
	if(trkHrs < 10){
		trkHrs = 0 + trkHrs.toString();
	}
	if(loading != true){
		time = hours + ":" + minutes + ":" + seconds;
		totalTrkTime = trkHrs + ":" + trkMin + ":" + trkSec;
	}
	else{
		time = undefined;
		totalTrkTime = undefined;
	}
};

///////////////////////////////end onEnterFrame///////////////////////////////


//controls the play button
play_mc.onRelease = play_mc.onReleaseOutside = function() {
	if(playing != true or paused == true){
		if(loading != true){
			if(paused == true){
				seconds = pos/1000;
				music.start(seconds, 0);
				paused = false;
			}
			else if (loading != true) {
				loading = true;
				music.loadSound(songInfo.content[songNum].path, false);
				//music.start(0,0);
			}
		}
	}
};

//controls the stop button
stop_mc.onRelease = stop_mc.onReleaseOutside = function () {
	//if(loading != true){
		loading =false;
		playing = false;
		paused = false;
		artist = undefined;
		title = undefined;
	//}
};

//controls the pause button
pause_mc.onRelease = pause_mc.onReleaseOutside = function(){
	if(playing == true){
		if(paused == false){
			pos = music.position;
			music.stop();
			//playing = false;
			paused = true;
		}
		else{
			seconds = pos/1000;
			music.start(seconds, 0);
			paused = false;
		}
	}
}

//controls the next button
next_mc.onRelease = next_mc.onReleaseOutside = function(){
	if(loading != true){
		skipLoop = true;
		nextSong();
	}
}

//controls the previous button
back_mc.onRelease = back_mc.onReleaseOutside = function(){
	if(loading != true){
		prevSong();
	}
}

loop_mc.radio_mc.onRelease  = shuffle_mc.radio_mc.onRelease = function(){
	if(this._parent._currentframe == 1){
		this._parent.gotoAndStop(2);
	}
	else{
		this._parent.gotoAndStop(1);
	}
	if(this._parent._name == "loop_mc"){
		if(loop == true){
			loop = false;
		}
		else{
			loop = true;
		}
	}
	if(this._parent._name == "shuffle_mc"){
		if(shuffle == true){
			shuffle = false;
		}
		else{
			shuffle = true;
		}
	}
	
}

//controls the sliders
vol_mc.slider_mc.slider.onPress = bal_mc.slider_mc.slider.onPress=pos_mc.slider_mc.slider.onPress=function () {
	whichDrag = this._parent._parent._name;
	this._parent.onMouseMove = function() {
		updateAfterEvent();
	};
	this._parent.startDrag(false, 0, this._y, 100, this._y);
};

vol_mc.slider_mc.slider.onRelease = vol_mc.slider_mc.slider.onReleaseOutside=
bal_mc.slider_mc.slider.onRelease = bal_mc.slider_mc.slider.onReleaseOutside=
pos_mc.slider_mc.slider.onRelease = pos_mc.slider_mc.slider.onReleaseOutside=
function () {
	if(whichDrag == "pos_mc"){
		if(pos_mc.slider_mc._x == 100){
			pos_mc.slider_mc._x = 99.5;
		}
		newPos = (pos_mc.slider_mc._x*(music.duration/1000))/100;
		music.stop();
		music.start(newPos, 0);
	}
	whichDrag = undefined;
	beenDragged = "pos_mc";
	this._parent.onMouseMove = undefined;
	this._parent.stopDrag();
	if(bal_mc.slider_mc._x > 47 and bal_mc.slider_mc._x < 53){
		bal_mc.slider_mc._x=50;
	}
};
scroller_mc.slider_mc.slider.onPress = function(){
	scrolling = true;
	
	this._parent.startDrag(0, this._parent._x, this._parent._parent.scrollBg_mc._y,
	this._parent._x, this._parent._parent.scrollBg_mc._y + this._parent._parent.scrollBg_mc._height);
}
scroller_mc.slider_mc.slider.onRelease = function(){
	scrolling = false;
	this._parent.stopDrag();
}

//controls the button that changes the time display from time elapsed to time left, and vice versa
timeButton_mc.onRelease = function(){
	if(timeWay == undefined){
		timeWay = "back";
	}
	else if(timeWay == "forward"){
		timeWay = "back";
	}
	else if(timeWay == "back"){
		timeWay = "forward";
	}
}
stop();


Ce qui me semble bizarre c'est que je ne vois pas où est la fonction qui charge le xml playlist dans le code, ce xml s'appelle "songInfo.xml".
mercredi 25 novembre 2009 à 23:07:44 | Re : Loader de XML

Orange73

Membre Club
Je peux voir ton xml albuminfos.xml ?


-- Orange73 --

"L'homme n'est pas fait pour travailler, la preuve c'est que cela le fatigue" (Voltaire)

mercredi 25 novembre 2009 à 23:09:04 | Re : Loader de XML

Orange73

Membre Club
C'est bon je l'ai trouvé là : http://www.musichrono.com/coverplay/albuminfo.xml


-- Orange73 --

"L'homme n'est pas fait pour travailler, la preuve c'est que cela le fatigue" (Voltaire)

mercredi 25 novembre 2009 à 23:09:37 | Re : Loader de XML

BBFUNK01

Le voici :
Code XML :
<artworkinfo>
	<albuminfo>
		<artLocation>album1.jpg</artLocation>
		<artist>MUSICHRONO</artist>
		<albumName>funk</albumName>
		<artistLink>'asfunction:funklist.load'</artistLink>
		<albumLink>'asfunction:funklist.load'</albumLink>
	</albuminfo>

	<albuminfo>
		<artLocation>album2.jpg</artLocation>
		<artist>MUSICHRONO</artist>
		<albumName>jazz</albumName>
		<artistLink>'asfunction:jazzlist.load'</artistLink>
		<albumLink>'asfunction:jazzlist.load'</albumLink>
	</albuminfo>
	
	<albuminfo>
		<artLocation>album3.jpg</artLocation>
		<artist>Kanye Wests</artist>
		<albumName>Graduation</albumName>
		<artistLink>http://www.kanyewest.com</artistLink>
		<albumLink></albumLink>
	</albuminfo>

	<albuminfo>
		<artLocation>album4.jpg</artLocation>
		<artist>A Fine Frenzy</artist>
		<albumName>One Cell In The Sea</albumName>
		<artistLink>http://www.google.com</artistLink>
		<albumLink>http://www.yahoo.com</albumLink>
	</albuminfo>

	<albuminfo>
		<artLocation>album5.jpg</artLocation>
		<artist>Amy Winehouse</artist>
		<albumName>Back to Black</albumName>
		<artistLink>http://www.google.com</artistLink>
		<albumLink>http://www.yahoo.com</albumLink>
	</albuminfo>

	<albuminfo>
		<artLocation>album6.jpg</artLocation>
		<artist>The Vines</artist>
		<albumName>Highly Evolved</albumName>
		<artistLink>http://www.google.com</artistLink>
		<albumLink>http://www.yahoo.com</albumLink>
	</albuminfo>

	<albuminfo>
		<artLocation>album7.jpg</artLocation>
		<artist>The Strokes</artist>
		<albumName>Is This It</albumName>
		<artistLink>http://www.google.com</artistLink>
		<albumLink>http://www.yahoo.com</albumLink>
	</albuminfo>

	<albuminfo>
		<artLocation>album8.jpg</artLocation>
		<artist>Yeah Yeah Yeahs</artist>
		<albumName>Maps - Single</albumName>
		<artistLink>http://www.google.com</artistLink>
		<albumLink>http://www.yahoo.com</albumLink>
	</albuminfo>

	<albuminfo>
		<artLocation>album9.jpg</artLocation>
		<artist>DangerDoom</artist>
		<albumName>The Mouse and the Mask</albumName>
		<artistLink>http://www.google.com</artistLink>
		<albumLink>http://www.yahoo.com</albumLink>
	</albuminfo>

	<albuminfo>
		<artLocation>album10.jpg</artLocation>
		<artist>Fort Minor</artist>
		<albumName>The Rising Tied</albumName>
		<artistLink>http://www.google.com</artistLink>
		<albumLink>http://www.yahoo.com</albumLink>
	</albuminfo>
	<albuminfo>
		<artLocation>album10.jpg</artLocation>
		<artist>Fort Minor</artist>
		<albumName>The Rising Tied</albumName>
		<artistLink>http://www.google.com</artistLink>
		<albumLink>http://www.yahoo.com</albumLink>
	</albuminfo>
	<albuminfo>
		<artLocation>album10.jpg</artLocation>
		<artist>Fort Minor</artist>
		<albumName>The Rising Tied</albumName>
		<artistLink>http://www.google.com</artistLink>
		<albumLink>http://www.yahoo.com</albumLink>
	</albuminfo>
	<albuminfo>
		<artLocation>album10.jpg</artLocation>
		<artist>Fort Minor</artist>
		<albumName>The Rising Tied</albumName>
		<artistLink>http://www.google.com</artistLink>
		<albumLink>http://www.yahoo.com</albumLink>
	</albuminfo>
	<albuminfo>
		<artLocation>album10.jpg</artLocation>
		<artist>Fort Minor</artist>
		<albumName>The Rising Tied</albumName>
		<artistLink>http://www.google.com</artistLink>
		<albumLink>http://www.yahoo.com</albumLink>
	</albuminfo>
	<albuminfo>
		<artLocation>album10.jpg</artLocation>
		<artist>Fort Minor</artist>
		<albumName>The Rising Tied</albumName>
		<artistLink>http://www.google.com</artistLink>
		<albumLink>http://www.yahoo.com</albumLink>
	</albuminfo>
	<albuminfo>
		<artLocation>album10.jpg</artLocation>
		<artist>Fort Minor</artist>
		<albumName>The Rising Tied</albumName>
		<artistLink>http://www.google.com</artistLink>
		<albumLink>http://www.yahoo.com</albumLink>
	</albuminfo>

</artworkinfo>


mercredi 25 novembre 2009 à 23:13:39 | Re : Loader de XML

BBFUNK01

Est-ce que tu vois quelque chose que je n'aurais pas fait correctement ?
ça fait plusieurs jours que je rame pour trouver la manière de charger ces différents xml et je suis sûr qu'il ne manque pas grand chose au code pour que ça marche, mais impossible de trouver la solution.

1 2 3 4

Cette discussion est classée dans : load, xml, loader, unevariable


Répondre à ce message

Sujets en rapport avec ce message

loader et xml [ par yvonig ] Saluch cha tous !j'ai fait un site quji marche pes mal, en flash dynamique, gallerie photo xml(panda gallerie), et livre d'or xlm, que j'ai aussi trou XML et Flash : probleme avec load [ par jdeboer ] Bonjour,Voila le probleme. Lorsque je charge un xml avec flash, il n'arrive pas a lire les xml standards.Flash ne veut que des xml ou tout est ecrit s loader XML / flash [ par bartoun ] Bonjour, Je cherche a mettre en place un module comme celui ci (tres bien fait d'ailleurs avec les sources commentées...tres interessant) J'ai tout m Load d'un xml rescent [ par SoyYo ] Bonjour Je suis en train de faire un mini forum en flash/PHP/XML, et en fait une fois que le message est poster je renvoie directement vers la page d loader un swf toujours en premier plan [ par samichlamich ] Salut,salut, Je crois que mon problême n'et pas trés compliqué, mais ça fait déjà un petit moment qu'il me tient, alors si quelqu'un peut m'aider ce XML vs Load [ par Aaron ] Bonjour à tous! Je souhaiterais savoir quel est l'intérêt d'utiliser le XML par rapport à sendAndLoad. Est-ce que la vitesse d'exécution est plus rap retrouver url qd on load un xml [ par tibo_c ] Bonjour tout le monde,J'aimerais dans la fonction appelée par un load XML retrouver l'url du XML chargé. Est-ce possible ? J'ai essayé comme ça mais ç load xml + cryptage décryptage [ par actaruss ] Bonjour à tous,J'ai un gros problème avec un fichier xml...Voilà, j'ai un swf en falsh qui loade des questions depuis un fichier xml :Le soucis est qu Pb avec load pour la 2 foi [ par hbakha2000 ] salutj'ai un flash qui charge (Load) des donneés a partire d'un fichies XML et j'ai integré ce flash dans une page PHP. cette page genéré le fichies X loadclip qui ne load pas [ par Inumber ] Bonjour,Je suis actuellement en train de refaire une galerie pour mon site, mais cette fois automatisée, c'est à dire comme toujours un xml créé par P


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,170 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales