Hi Marco,
i'm glad you like my articles :)
I will work on multi categories and i think the 2.0 version of fullscreen gallery will allow them.
Anyway, if you'd like to try, you should work with double-dimension Arrays and this kind of XML:
HTML Code:
<?xml version="1.0" encoding="UTF-8"?>
<gallery>
<category1 name='diary'>
<image>diary/pic_0.jpg</image>
<image>diary/pic_1.jpg</image>
<image>diary/pic_2.jpg</image>
</category1>
<category2 name='wedding'>
<image>wedding/pic_0.jpg</image>
<image>wedding/pic_1.jpg</image>
<image>wedding/pic_2.jpg</image>
<image>wedding/pic_3.jpg</image>
<image>wedding/pic_4.jpg</image>
<image>wedding/pic_5.jpg</image>
</category2>
<category3 name='nature'>
<image>nature/pic_0.jpg</image>
<image>nature/pic_1.jpg</image>
<image>nature/pic_2.jpg</image>
</category3>
<category4 name='people'>
<image>people/pic_0.jpg</image>
<image>people/pic_1.jpg</image>
<image>people/pic_2.jpg</image>
<image>people/pic_3.jpg</image>
</category4>
<category5 name='fruit'>
<image>fruit/pic_0.jpg</image>
<image>fruit/pic_1.jpg</image>
<image>fruit/pic_2.jpg</image>
</category5>
</gallery>
With this sample of Document Class, you can store each data into an Array and gets avery value:
Code:
package
{
import flash.display.MovieClip;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.xml.*;
import flash.geom.ColorTransform;
public class LoadingXML extends MovieClip
{
private var my_array:Array;
public function LoadingXML()
{
my_array=new Array();
this.loadXML();
}
private function loadXML():void
{
var loader:URLLoader=new URLLoader();
loader.addEventListener(Event.COMPLETE,completeHandler);
var request:URLRequest=new URLRequest('gallery.xml');
try
{
loader.load(request);
}
catch(error:Error)
{
trace('Impossibile caricare il documento.');
}
}
private function completeHandler(event:Event):void
{
var loader:URLLoader=URLLoader(event.target);
var result:XML=new XML(loader.data);
var myXML:XMLDocument=new XMLDocument();
myXML.ignoreWhite=true;
myXML.parseXML(result.toXMLString());
var node:XMLNode=myXML.firstChild;
var n:int=node.childNodes.length;
var names_array:Array=new Array;
for(var i:int=0;i<n;i++)
{
names_array.push(node.childNodes[i].attributes['name']);
var pics_array:Array=new Array();
var s:int=node.childNodes[i].childNodes.length;
for(var j:int=0;j<s;j++)
{
pics_array.push(node.childNodes[i].childNodes[j].firstChild.nodeValue);
}
my_array.push(pics_array);
}
my_array.push(names_array);
// first index container[] = categories name and second index conteiner[] = picture of the category you called with the first index
// so for example, the next line will get the ' people ' category ( index 3 of my_array ) and the 3rd picture ( pic_2.jpg ) ----- you can easy browse your array
trace(my_array[3][2]);
}
}
}