Actionscript 2, Flash, Flash _, Tutorials, Web developer

Flash image gallery example (Actionscript 2) – using PHP to list images from folder

this is simple gallery example for AS2
gallery is nothing special, ease to use and implement

interesting thing about this example is that you pass a folder, and PHP side gathers image list from a folder and returns it to the Flash in XML form together with images widths and height which makes it more easier to implement this sort of galleries like I’ve made

so from this example you can see :

  • PHP serving XML to Flash
  • PHP getting image size (width and height)
  • Flash loading XML
  • Flash creating elements on stage using library
  • loading external images
  • and more…

this example is for beginner level

example :

if you have any questions about PHP or Flash side please post it here

EDIT: sorry for wrong links and config. Everything is corrected now and fully functional
thanks people who noted me about errors!


59 thoughts on “Flash image gallery example (Actionscript 2) – using PHP to list images from folder

  1. Wow thanks! I’ve been displaying my images in a very similar way but this is a much easier to build and maintain a site. What would the be the simplest way to ad a link to the top of the page? Link on top of my current site.

  2. Beebs says:


    I really like this gallery. Unfortunately my server does not have PHP. Can you please help me to provide the XML version only? Can you please give me ahint for the xml file structure for the start?

    Thanks a lot

  3. @David and all :

    yes you’re site could definitly use this gallery
    you can add anything you want into the FLA file (logos, contant links …) and recompile it and use it on your site

  4. Beebs says:

    Thanks a lot for repply Mr.Steel. I really appreciate it.
    I have further question/request :

    With the XML version, How possible to check the width and the height through Actionscript dynamically – so that the width and height property does not need to be listed in the XML file?

    Thanks again.

  5. srinivas says:

    Thanks for good stuf with php..

    I want one help I have flash file that reads data from php and builts a link .
    by clicking this link can we get flash pop up window?? pls help ??

  6. Pingback: Free Flash Applications :Image Galeries, FLV Players, MP3 Players | Flex Tech

  7. Thanks for a Flash gallery simple enough for me to understand and alter bits. Going acrzy looking for where to alter the size and colour of the borders around the images though… Can you point me to the right bit? cheers

  8. Bing says:

    I have implemented your flash on my site. Just wonder what other options that I can use. I am looking for options to load the image, starting from the left instead of the center. Also, want to see if there is an option to show file name. Thx

  9. Pingback: Christian Web Design Resources » Blog Archive » Free Flash Resources

  10. Pingback: Free Flash Resources | Christian Web Design Tutorials

  11. Pingback: Free Flash Resources | Christian Web Design Blog

  12. Dwaine says:


    i need to have different folders for different galleries, ie, not all images will be in the images folder?
    Where should I change the images folder variable, cant seem to change it correctly! 😦
    Please help!

  13. Pingback: Ücretsiz Resim Galerileri Üzerine Bir İnceleme | Away4m

  14. keyon says:

    I need so help i have this code it works a little,
    the only problem with it is that when i try to place the code and images in a MClip to place it on the Stage. it does not work please help

    all i need is a good working image scroll gallery for AS2 with no xml

    panel.onRollOver = panelOver;

    function panelOver() {
    this.onEnterFrame = scrollPanel;
    delete this.onRollOver;

    var b = stroke.getBounds(_root);

    function scrollPanel() {
    if(_xmouseb.xMax || _ymouseb.yMax) {
    this.onRollOver = panelOver;
    delete this.onEnterFrame;

    if(panel._x >= 89) {
    panel._x = 89;

    if(panel._x <= -751) {
    panel._x = -751;

    var xdist = _xmouse – 400;

    panel._x += Math.round(-xdist / 7);

  15. Felipe says:

    Please, help me.

    How I can change the width/height of the image?

    I need to do this in a site, but I don’t know AS very well.

    If someone explains to me, shows an example too.

    Thank you a lot!

  16. change width /height of which image?

    this gallery automatically takes width and height of image in folder and bring it through XML to Flash …

  17. Mr Steel, this is awesome! I just have one problem; When i place this inside a movieclip TempMC seem to get the right width and height but it does not load the images. Do you have a solution to this? I would realy appreciate it!

  18. jsoh says:

    Great bit of flash!

    Is there away to get the php to order the images by name not date?

    Also is there an engligh version of the class.get.files?


  19. Rajib Datta says:

    when i wanted to run gallery .fla file,the value of xml.firstChild.childNodes.length becomes undefined.could you tell me why?

  20. Hi Mr. Steel, I want to say thank you for this turtorial. I would like to use it, but it’s not working for me. “THE IMAGES ARE NOT SHOWING UP” I was reading some up there about the comments from :

    ” Oleg // January 8, 2008 at 11:28 pm | Reply

    “Check the links in your example – it’s pointed to localhost ”

    Does it have something to do with my file path? I have the folder on my desktop. Please let me know,I would like to use this galerry.

    Thanks in advance

  21. Hello mr.steel!
    Thanks for the post, it’s just what I’m looking for to this school project I’m doing. (one part being an autoupdating image bank)
    But, I have the same problem as TiLou, I can’t see the images…
    I have to say I have no experience with php, so do you have to upload the php file to a server or something?


  22. Ron says:

    Hi, this is AMAZING!
    I have it working fine although the images overlap. They all vary in size but aren’t very big. What is the deal with numbering the image files? Is there a proper way to do it?

  23. Ron says:

    I figured out the overlap.

    Just don’t understand the file numbering and how to get the images in a prefered order.

  24. Ron says:

    Excellent! Thankyou.

    Also, is it hard to add a button that returns it back to the first image? I have alot of images and its tedious clicking back through

  25. Ron says:

    I’m really struggling with the order. I have little PHP knowledge, could you make it simpler? If thats possible!

  26. Pingback: 2010 in review « Cyberspace Nova

  27. Rose says:

    Hello…Not sure if you are still answering questions to this post…One question: How can I change the spacing between the images in actionscript? Thank you.

  28. saadat says:

    SIR its not wroking even i have changed the link frm local host m testing it to my local machine but not displaying pic

  29. This is why you will need to take advantage of this variation basic principle when coming up with your current positions to enable you
    to take into consideration the odds to your advantage in regards to getting much more receiving positions along
    with a lot fewer loss. Based upon cures include stated
    in regards to brokerage house businesses, affiliate marketor payouts for you to buyers, and also the price associated with Learn binary options considering their particular root belongings, it is clear
    which this type of purchase method is as legit since the far more renowned types of trading currently.

    We hope to find out an individual buying and selling before long!
    Whenever they assume that the market goes in place,
    they are going to invest in precisely what is referred to as a new Telephone selection.
    Learn binary options is usually a successful and also new path for
    people to industry as well as make money using the actual comfort and ease of their own homes.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s