Faculty of Design / Video Tutorials / Flash - AS2 - Flash and XML / How to create a gallery in Flash using XML data
How to create a gallery in Flash using XML data
Author: Bill Trikojus
Using XML with Flash makes it easy to update the content of your Flash website. This is particularly useful for portfolio websites that need to be constantly updated with your latest work. This tutorial will show you how to store your portfolio data in an XML file and create a dynamic web portfolio in Flash. This is what you will be making.
2008-05-08: Diego said: nice tutorial it works just fine, congratulations. I just wanted to know, what if we needed to add a pre loader for the images? where do we add it? Thanx a lot
2008-05-08: Bill Trikojus said: Just make a movieclip that constantly watches the holder that the big images are loaded into and shows itself and the loading status whenever the holder is not fully loaded. Pretty sure this 'how to build a website' tutorial shows how to do that.
cheers
cheers
2008-05-29: Bill Trikojus said: Just added a new part to the tutorial to show how to preload the big images
cheers
2008-07-01: Aloseous said: itz good.
2008-07-19: Melissa said: Nice tutorial! How do you make it so the slide auto plays.That way you don't have to put a bunch of buttons if you have many images. Something like a slideshow possibly with next and previous controls on it to skim trough the gallery.
2008-07-27: August said: Loved the tute! My images vary in size and shape so I would rather that they were aligned centrally to the holder_mc. Is this possible?
2008-07-27: Bill Trikojus said: Sure. Basic concept is this
//define the width height of big image area
w=400;
h=400;
//define the x and y of big image area
x=300;
y=100;
then when the new big image is fully loaded you get the width and height of the holder and position it inside that area
//eg
holder_mc._x=x+(w-holder_mc._width)/2;
//same for y
cheers
2008-07-29: Melissa said: I was thinking of something like a slideshow with movie controls that enable you to pause/play or go to next slide or previous.
2008-08-11: August said: Hi again! Thanks for the tip, it looks much better now. I was wondering about something else though. Is there a way to load a different xml file after the swf file has started? I would like to load in different different sections of pohotos.
2008-08-11: Bill Trikojus said: Sure. Just format all the XML files the same, load a default one in at the start and make some buttons that call the .load method of your existing XML object providing a different xml file as the parameter. When the new xml file loads, the existing onLoad finction will fire and your interface will be built. You might need to write some code at the top of the function that clears the existing thumbnail scroller to make way for the new one - check out removeMovieClip() to do this
cheers
2008-08-28: Augst said: Hi! Hope I'm not askong too many questions here :P I tried to load another XML file, and it loaded in as it should, but I can't seem to get the removeMovieClip() right. It just removes the last of the thumbnails, but the new thumbnails start in the position after taht anyway. I even tried with a loop. How should I set it up?
2008-08-28: Bill Trikojus said: Hard to know without seeing your code. I can't remember the instance names in the tute but it would be something like
for(i=0;i<50;i++){
holder_mc['image'+i].removeMovieClip();
}
//reset starting x pos
//reset starting y pos
//load new xml file
Might be best to post the question on a flash forum like actionscript.org
cheers
2008-09-04: Guillaume Rolland said: Hi, I've noticed that this tutorial only works if published in Flash Player 6 and not in 7 or 8. Unless I am mistaken, I believe something doesn't work right with the attachMovie.
What could I do to correct this?
2008-09-04: Bill Trikojus said: It should work fine. In flash 7 actionscript became case sensitive so make sure you don't have attachmovie instead of attachMovie etc. I can't recall if it uses a prototype or not but if it does it needs to be MovieClip.prototype and not Movieclip.prototype.
Hope that helps
2008-09-07: Guillaume Rolland said: Thanks for the fast reply, and you were right, there is no problem in version 7 or 8. Just got a bit lost in the code was all. Thank You.