Thread: xml gallery
View Single Post

  #6 (permalink)  
Old 16-03-08, 02:17
z1784 z1784 is offline
Junior Member
 
Join Date: Mar 2008
Posts: 4
Rep Power: 0
z1784 is on a distinguished road
Re: xml gallery

It worked great. Thanks so much.

Here's the code I used:

Code:
var imageLoader:Loader;
var xml:XML;
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();


var numClips:int=10;
var columns:int=2;




xmlLoader.load(new URLRequest("images.xml"))
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

function xmlLoaded(event:Event):void
{
    xml = XML(event.target.data);
    xmlList = xml.children();
    
 for(var i:int = 0; i < xmlList.length(); i++)
    {
        imageLoader = new Loader();
        imageLoader.load(new URLRequest(xmlList[i].attribute("thumb")));
        imageLoader.x = 10+( i % columns )*65;
        imageLoader.y = 10+(Math.floor(i/columns)*65);;
        imageLoader.name = xmlList[i].attribute("source")
        addChild(imageLoader);
        imageLoader.addEventListener(MouseEvent.CLICK, showPicture);
  
   
        
    
}}

function showPicture(event:MouseEvent):void
{
   if(imageLoader)
     {removeChild(imageLoader)}
    imageLoader = new Loader();
    imageLoader.load(new URLRequest(event.target.name));
    imageLoader.x = 200;
    addChild(imageLoader);
    
    
    
}
Reply With Quote