A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [F8] Preloading many thumbnails

  1. #1
    Senior Member
    Join Date
    Apr 2003
    Location
    MA
    Posts
    273

    [F8] Preloading many thumbnails

    I'm creating a thumbnail gallery which reads in data from an XML file. Currently I read in all the XML data in a for loop, put all the data into arrays, and create all the movie clips with the thumbnails. The only problem is that since I create all of the thumbnail clips in the for loop, the images are loaded like a website does it, and they pop up randomly one at a time on the screen until it's all complete.

    I want to know how to find out when each finishes loading individually, so I can add to a counter and test to see if all xx of them have loaded. I've tried to use a MovieClipLoader in my for loop:

    Code:
    mcl = new MovieClipLoader();
    createEmptyMovieClip("container", _root.getNextHighestDepth());
    mcl["onLoadComplete"] = Delegate.create(this, thumbLoaded);
    mcl.loadClip(thumbPath, _root.container);
    which in theory should call the "thumbLoaded" method when the thumbnail is done loading. (The thumbLoaded method just traces a statement).

    However, when I run the flash file, the thumbLoaded method is only called once, when the for loop has run its course. I do a trace in the for loop and a trace in the thumbLoaded method, and the for loop traces all complete before the thumbLoaded trace does.

    I hope I didn't explain my problem too poorly. Can anyone help make sure all of the images get preloaded? The rest is easy enough to get the movie to play when they're all done, but I can only get it to say that one has finished.
    Last edited by DelvarWorld; 08-04-2006 at 02:36 AM.

  2. #2
    Senior Member
    Join Date
    Apr 2003
    Location
    MA
    Posts
    273
    bump from page 2

  3. #3
    Senior Member
    Join Date
    Apr 2003
    Location
    MA
    Posts
    273
    bump from page 3...

  4. #4
    All 1s and 0s dmonkey's Avatar
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Posts
    606
    Hi,

    If you're writing this code in a for loop, then all that is going to happen is that you overwrite the MovieClipLoader each time, so you end up only getting the last trace. Place everything except the call to loadClip outside the 'for' loop. You should then get traces for all the clips loading.
    "If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center