2 Replies Latest reply on Oct 16, 2006 1:17 PM by ccaptainsubzero

    How Do I Tell If A JPEG/SWF Has Loaded/Is Loading?

      I did a site for a photographer, loading an XML file and then loading all the thumbnails and images.

      At his request I loaded ALL the images at the beginning (looped through XML file and loaded images one by one -- loading each when previous one loaded)

      Needless to say, this approach has a long front-loading time (which I thoguht it would), and he wants to change it so that each image is loaded as you click on it, AND the remaining images are loaded in the background.

      What's the best way to go about this? To have the other images load on onEnterFrame? And then in the meantime if I want to load a particular image I can do loadMovie() on it when the user wants to see it.

      But if I'm populating the array of other images in the background and the user wants to see one I'm in the process of loading, how do I handle that? Set a flag that says "I'm loading this image", and another that says "this image is loaded"?

      Do I need to use flags, or is there an inehrent property of the movie clilp that I can test?


        • 1. Re: How Do I Tell If A JPEG/SWF Has Loaded/Is Loading?
          TimSymons Level 1
          If you use the MovieClipLoader class, it has inherent events that you can use to determine if the loading is still in progress or if the loading has been completed.

          • 2. Re: How Do I Tell If A JPEG/SWF Has Loaded/Is Loading?
            ccaptainsubzero Level 1
            Thanks. Then I could store a MovieClipLoader in my picture-associated object and check when coming in from the outside to see if <> undefined ?

            My question has to do with "concurrency" -- that is, if in one part of the program I'm running through an array of these picture-objects, creating MovieClipLoaders and storing them in my picture-object, but elsewhere in the program I'm looking for mouseclicks and if a user wants to view a particular picture then I go ahead and check the associated picture object to see if it's already loading -- what lag, if any, is there in assigning the MovieClipLoader in my bulk loading in the array and checking for it in my mouseclick handling?

            That is to say, if I have two parts of the program both trying to load the same picture, I need a "lockout" so that they don't both try to load it at the same time -- and this "lockout" would be the MovieClipLoader -- one or the other will do new MovieClipLoader() and the other will check for this before trying to create it. But what I'm curious about is whether there is a lag between one part of the programming checking for this and creating it, and the other part checking for it -- and how to deal with that.