5 Replies Latest reply on Mar 28, 2011 4:49 AM by jexer

    How to get a list of images from a folder?

    jexer

      Hey.

       

      I want to create a flash app where the site owner can simply put images in a folder, and the flash app finds all the images in the folder, and will display a slide show from them.

       

      Is there any way to list all files in a folder, so I can load them without prior knowledge of their names? I'd prefer not to have to tell a dumb customer what an XML file is and how to edit it, and also the images need to keep their original names so I can get titles for the images from the names.

       

      .. in Flash.

        • 1. Re: How to get a list of images from a folder?
          Rothrock Level 5

          Nope. Flash can't do this on its own. You can do it with AIR.

          1 person found this helpful
          • 2. Re: How to get a list of images from a folder?
            ChrisH

            Hi Jexer,

            not sure if you could use this to help.  I came across it when looking for something else - I haven't used it myself yet.

             

            From AS2 language reference:

            "The FileReferenceList class provides a means to let users select one or more files for uploading. A FileReferenceList object represents a group of one or more local files on the user's disk as an array of FileReference objects. For detailed information and important considerations about FileReference objects and the FileReference class, which you use with FileReferenceList, see the FileReference class. "

             

            If you can get the user to choose the files in their localtion to simply populate the array, without having to upload, you may be able to access that array to dynamically populate a series of movieclips (e.g. loadclip), and then specify the selected jpgs from the array to load.

             

            On the face of it, you wouldn't be able to stop them selecting files other than Jpgs, but you could possibly traverse the array and query the names to remove anything taht didn't end in the extensions you wanted to target.

             

            If you can successfully access the array, I guess you could then make the XML at runtime.

             

            Would be great if you could repost your outcome.

             

            Regards

            Chris

            1 person found this helpful
            • 3. Re: How to get a list of images from a folder?
              ChrisH Level 1

              Reading a little more on it, in the FileReference.browse method, you can specify the file types you want to allow to appear in the browse dialogue box.e.g.

               

              browse ([{description: "Images", extension: "*.jpg;*.jpeg"}]);

               

               

              Regards Chris

               

              • 4. Re: How to get a list of images from a folder?
                Ned Murphy Adobe Community Professional & MVP

                You will need some server-side scripting such as PHP to read a folder's contents.

                • 5. Re: How to get a list of images from a folder?
                  jexer Level 1

                  Thanks for the answers.

                   

                  I suppose I'll let the site owner to tinker with the XML to add images for now.

                   

                  Chris H, thanks for the tip.

                  I think later on I'll try the dialog box apporach, and/or build another app for editing the XML (or find a component to do that).

                   

                  I'll post here if i'll get to do that.