bonjour,
je me permet de poster un message sur le forum car j'ai un souci que je n'arrive pas à résoudre sur mon action script
le but de mon action script est de lire dans un fichier xml de playlist pour aller chercher un mp3 et le lire, seulement le code ne semble pas aller au bon noeud xml puisque certains liens fonctionnent mais n'envoient pas le mp3 demandé mais un autre, et certains boutons n'envoient rien du tout
merci d'avance à celui ou celle qui pourra me filer un coup de main
j'ai tenté de modifier la valeur k = 2 et k=k+1; le résultat change mais je ne retombe pas sur mes pieds :p
voici mon action script
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 MovieClip.prototype.setDescription = function(val) { this.description_txt = val; }; MovieClip.prototype.getDescription = function() { return this.description_txt; }; var k:Number = new Number(); k = 2 ; document= new XML(); //création de l'objet XML document.ignoreWhite=true; //ignorer les sauts de ligne document.load("playlist.xml"); //charge le document _root.document.onLoad=function(){ //quand le chargement du document est terminé , lancement de l'animation var nb = document.firstChild.childNodes.length; var i=0; _root.createEmptyMovieClip("playlist",6); var decalY:Number = 150; var tl = document.firstChild.firstChild; while(tl != null) { if (tl.nodeName == 'trackList') { var tck = tl.firstChild; while(tck != null) { var tc = tck.firstChild; var ann = ""; var loc = ""; var inf = ""; var img = ""; var ide = ""; while (tc != null) { if(tc.nodeName == 'annotation') { ann = tc.firstChild.nodeValue; } //texte var txt = _root.playlist.createTextField("txt"+i, 100+i, 370, decalY, 400, 20); txt.text = ann ; //bouton var button = _root.playlist.createEmptyMovieClip("button"+i, 150+i); button.attachMovie("btn_play", "button_n"+i, 180+i); button._x = 300; button._y = decalY+2; button.addProperty("path", MovieClip.prototype.getDescription, MovieClip.prototype.setDescription); button.path = k; k=k+1; button.onPress = function() { //fonction qui appelle le lecteur avec le numéro de la chanson voulu. _root.mp3player.mp3player.playSong(this.path); } tc = tc.nextSibling; } i++; decalY = txt._y + 30; tck = tck.nextSibling } } tl = tl.nextSibling; } } stop();
et le fichier xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 <?xml version="1.0" encoding="UTF-8" ?> <playlist version="1" xmlns="http://xspf.org/ns/0/"> <trackList> <track> <annotation>NOUVEAUTITRE</annotation> <location>../tracks/mp3/ASSASSIN.mp3</location> <image>../tracks/vignette/8_TEST60MO_!!_Din.jpg</image> </track> <track> <annotation>LEA 2mo</annotation> <location>../tracks/mp3/LEA_2mo.mp3</location> <image>../tracks/vignette/7_LEA_2mo.jpg</image> </track> <track> <annotation>MOGO 22MO</annotation> <location>../tracks/mp3/MOGO_22MO.mp3</location> <image>../tracks/vignette/6_MOGO_22MO.jpg</image> </track> <track> <annotation>MANDY 12MO</annotation> <location>../tracks/mp3/MANDY_12MO.mp3</location> <image>../tracks/vignette/5_MANDY_12MO.jpg</image> </track> <track> <annotation>Schtroumphs</annotation> <location>../tracks/mp3/Schtroumphs.mp3</location> <image>../tracks/vignette/4_Schtroumphs.jpg</image> </track> <track> <annotation>ASSASSIN</annotation> <location>../tracks/mp3/ASSASSIN.mp3</location> <image>../tracks/vignette/3_ASSASSIN.jpg</image> </track> </trackList> </playlist>
Partager