3 Replies Latest reply on May 19, 2006 5:50 PM by Rothrock

    Something to chew on

      What I have is an image viewer that loads external images when the next button is pressed, at this stage the images are in a set naming structure 1.jpg / 2.jpg etc etc

      Now what I want to do is load the images in without defining the name as “hard code” what I want to do is load the images in via numerical/alphabetical order.

      Say my string of images is 1.jpg - 2.jpg - 3.jpg - 3a.jpg - 4.jpg etc so flash would look at the file names and load the next numerical/alphabetical sequenced image in?

      Any ideas would be helpful, and thanks
        • 1. Re: Something to chew on
          Rothrock Level 5
          No way to do this with Flash alone. Flash can't look through a folder and find the file names. So you will have to use some back end thing like PHP to provide Flash with the names or you will have to come up with something else.

          A simple solution is to create a simple document that holds the names you want to load. This could be an XML or text document and then use either XML or LoadVars classes to load the information.

          Once the information is provided – either from a back end system or datafile – you can use the MovieClipLoader class to load the images in any order you desire.
          • 2. Re: Something to chew on
            blemmo Level 1
            I'm not sure what happens when you try to load an non-existing file. If there's a way to detect that the file doesn't exist (maybe through getBytesTotal()), then it could be possible to just load the next file when the button is pressed, and in case the file doesn't exist, start again with the first image.
            This is just an idea, and would need special named files (1.jpg, 2.jpg ...), but maybe it's worth a try. If you test it, please tell if it's working.

            • 3. Re: Something to chew on
              Rothrock Level 5
              With the MovieClipLoader there is an onLoadError event. You could also use a setInterval and check the getBytesTotal or getBytesLoaded to see if the file is there. You can also use the XML class to "load" an image – it doesn't care what format the file is.If it doesn't load then it will return "false" to the XML.onLoad event. If it returns true then you know the file exists and can reload – should be faster 'cause the file is in cache – it with loadMovie.

              The only other problem I see is that the OP has listed files like 1, 2, 3, 3a, 4… That will make the "load and see" approach quite complex – doable, but complex. Additionally I've found (unless I'm doing it myself) that it is quite difficult to get people to conform file names to a predefined system. So if this system will require collaboration my personal view is that it would be doomed.