Bonjour,
je tente depuis plusieurs jours de créer une galerie dynamique avec plusieurs catégories. J'ai "réussi" à un détail prés, lorsque l'on clic sur une nouvelle galerie, les images s'ajoute à la galerie précédente.
J'ai tester plusieurs solution mais aucune n'a été concluante.
Merci ;)
Je vous laisse mon code :
myXMLLoader.load(new URLRequest("gallery.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
var myXML:XML = new XML(e.target.data);
columns = myXML.@COLUMNS;
my_x = myXML.@XPOSITION;
my_y = myXML.@YPOSITION;
my_thumb_width = myXML.@WIDTH;
my_thumb_height = myXML.@HEIGHT;
my_collection = myXML..COLLECTION;
my_titre_total = my_collection.length();
creatext();
createContainer();
myXMLLoader.removeEventListener(Event.COMPLETE, processXML);
myXMLLoader = null;
}
///////////////////////////////////////////////////////
function creatext():void {
for (var i:Number = 0; i < my_titre_total; i++) {
var monBouton:SimpleButton = new SimpleButton();
var titre = my_collection[i].@titre;
var normal:TextField = new TextField();
var survol:TextField = new TextField();
var clic:TextField = new TextField();
normal.text = survol.text = clic.text = titre;
survol.textColor = 0xFF0000;
clic.textColor = 0x0000FF;
monBouton.upState = normal;
monBouton.overState = survol;
monBouton.downState = clic;
monBouton.hitTestState = normal;
monBouton.x = 20;
monBouton.y = thumb_holder.y + (i*20);
monBouton.name = titre;
this.addChild(monBouton);
monBouton.addEventListener(MouseEvent.CLICK, callThumbs);
}
}
///////////////////////////////////////////////
function createContainer():void {
container_mc = new MovieClip();
addChild(container_mc);
}
function callThumbs(e:MouseEvent):void {
my_tri_recupe = my_collection.( @titre == e.target.name);
my_total_recupe = my_collection.( @titre == e.target.name).IMAGE.@THUMB.length();;
for (var i:Number = 0; i < my_total_recupe; i++) {
my_tri = my_tri_recupe.IMAGE[i].@THUMB;
var thumb_url = my_tri ;
var thumb_loader = new Loader();
thumb_loader.load(new URLRequest(thumb_url));
thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
thumb_loader.name = i;
thumb_loader.x = (my_thumb_width+60)*x_counter;
thumb_loader.y = (my_thumb_height+30)*y_counter;
if (x_counter+1 < columns) {
x_counter++;
} else {
x_counter = 0;
y_counter++;
}
}
function thumbLoaded(e:Event):void {
var my_thumb:Loader = Loader(e.target.loader);
container_mc.x = thumb_holder.x+20;
container_mc.y = thumb_holder.y+20;
container_mc.addChild(my_thumb);
container_mc.mask=thumb_holder;
my_thumb.contentLoaderInfo.removeEventListener(Event.COMPLETE, thumbLoaded);
}
}