PDA

Volledige versie bekijken : dynamische thumb gallery


horicolonoma
%Europe/Berlin %898 %2008, 21:33
Ik kom telkens tegen hetzelfde probleem aangelopen als ik websites creeer.

Een simpele dynamische thumbgallery...kan toch niet zo moeilijk zijn?

Dit is het idee...

XML-file bevat tekst, url naar de foto's en url naar de thumbs
Flash:
- Variabele: Array die alles opslaat van de XML
- maakt een loop en in die loop worden Movieclips gemaakt volgens de array die je dan één voor één aan kunt klikken.
- als er geklikt wordt op een bepaalde thumb, komt de grote foto tevoorschijn die dan gehaald wordt uit de XML

Vertrouw me...ik heb al heel veel tutorials gedaan hierover. Waaronder ik tweemaal toe die extended dynamic thumb gallery.
Maar het wil nu niet lukken...

kunnen jullie me helpen?

stop();
//maak variabeles aan
var xl:XML = new XML ();
xl.ignoreWhite = true;

var urls:Array = new Array ();
var captions:Array = new Array ();

//start van de XML
xl.onLoad = function (){
var photos:Array = new Array ();
//herhaling zodat de filmkes naast elkaar zouden moeten komen te staan
for (i=0;i<photos.length;i++){
instance = "a"+i
urls.push (photos[i].attributes.url);
captions.push(photos[i].attributes.caption);
this.createEmptyMovieClip (instance, this.getNextHighestDepth);
instance._x = 10*i
instance._y = 10
instance.loadMovie(urls[i])
}
trace (i)//geeft alleen 0 weer
}
xl.load("Portarch1.xml");

en hier is mijn xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<slideshow>
<photo url="Portarch/1.jpg" caption="" />
<photo url="Portarch/2.jpg" caption="" />
<photo url="Portarch/3.jpg" caption="" />
</slideshow>

Dit is dus nog maar om mijn thumbnails te vertonen. Wat dus niet gebeurt. Trace (i) geeft hij alleen maar 0.

De url's van de foto's zijn correct.

Jan
%Europe/Berlin %925 %2008, 22:13
Je maakt een array photos aan maar je stopt er niks in dus is de length 0 en dus gebeurt je for loop niet. Je moet daar de childNodes instoppen (dat is een array).
childNodes (XMLNode.childNodes property)
public childNodes : Array [read-only]

An array of the specified XML object's children. Each element in the array is a reference to an XML object that represents a child node. This is a read-only property and cannot be used to manipulate child nodes. Use the appendChild(), insertBefore(), and removeNode() methods to manipulate child nodes.

Verder misschien ook de encoding van je xml file aanpassen.

Groeten,
Jan