snippets / loader une image d'un fichier xml en AS3

Language: None - First posted by juliend2 on 2008-04-20 16:54 (5 months, 3 weeks)
Link to the snippet: http://www.friendsnippets.org/snippet/257/

bâtir l'URL du URLRequest pour prendre le fichier xml.

 1 xmlLoader.load(new URLRequest("xmlSpecs/"+ nomSerie +"/"+nomModele+"_"+ lang +".xml"));
2 // lorsque le fichier xml est fini de loader, on part la fonction xmlLoaded
3 xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
4
5 function xmlLoaded(event:Event):void
6 {
7 var nombreImages:int = specsConteneur.numChildren;
8 for(var i:int=0; i<nombreImages; i++){
9 specsConteneur.removeChildAt(0);
10 }
11 xml = XML(event.target.data); // le fichier xml
12 xmlList = xml.children(); // la liste d'items dans le fichier xml
13 //trace('xmlLoaded');
14 imageLoader = new Loader(); // on crée une variable Loader
15 imageLoader.load(new URLRequest(xmlList[0].attribute("source"))); // on load ce qu'il y a dans l'attribut "thumb" du fichier xml
16 imageLoader.x = 241; // on dit sa position x dans les thumbnails
17 imageLoader.y = 63; // on dit sa position y dans les thumbnails
18 specsConteneur.addChild(imageLoader); // on affiche imageLoader dans la liste d'affichage
19
20 }
In order to post a comment, you should have a friendsnippet account. Please sign-in.

0 comments

Apr '08
  • bâtir l'URL du URLRequest pour prendre le fichier xml.

Common Tags



snippet History

Apr '08