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
|
<fx:Script>
<![CDATA[
import mx.controls.Image;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import spark.effects.animation.Animation;
public function init():void{
XmlFile.send();
}
public function xmlFault(evt:FaultEvent):void{
trace(evt.message);
}
public function xmlResult(evt:ResultEvent):void{
var myCat:String = new String("Bagues");
// Récupération de la liste des images
var xmlList:XMLList = XML(evt.result).children();
// Recherche de la catégorie
for(var i:int = 0;i<xmlList.length();i++)
{
if(xmlList[i].name == myCat) // Si c'est la catégorie cherchée
{
for(var j:int = 0;j<xmlList[i].photos.photo.length();j++) // On liste toutes les photos de cette catégorie
{
// On crée une nouvelle image
var myImg:Image = new Image();
myImg.source = "img/" + myCat + "/small/" + xmlList[i].photos.photo[j].name + ".jpg";
myImg.alpha = 0;
myImg.addEventListener(Event.COMPLETE,showTileImg);
// On l'ajoute à la liste
myTileList.addElement(myImg);
}
}
}
}
public function showTileImg(evt:Event):void
{
Image(evt.target).alpha = 100;
}
]]>
</fx:Script>
<fx:Declarations>
<mx:HTTPService url="img.xml" id="XmlFile" resultFormat="xml" result="xmlResult(event);" fault="xmlFault(event)"/>
</fx:Declarations>
<s:VGroup x="0" y="0" width="100%" height="100%">
<s:DataGroup width="100%" height="500"/>
<s:Scroller width="100%" height="200">
<s:HGroup x="127" y="50" width="100%" height="200" id="myTileList">
</s:HGroup>
</s:Scroller>
</s:VGroup> |
Partager