SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict djh's Avatar
    Join Date
    Apr 2000
    Location
    Long Beach, CA
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    preloading external swfs using loadMovie

    I'm seriously getting my butt kicked in with this, please help!
    I'm trying to:
    1) load external swf into a new mc created using createEmptyMovieClip
    2) show size and loaded size of the external swf using getBytesTotal() and getBytesLoaded()
    3) display a progress bar based on bytes loaded
    Now, I presume one can do this a couple of different ways. You can build the preload into the external swf itself (I have tried this but had problems - the swf wouldn't display until it was mostly or fully loaded, so the progress bar wouldn't be seen...) or, I would think you can do it the way I'm trying here...
    From my main movie, i have three frames:

    frame 1:
    ==========
    Code:
    _root.createEmptyMovieClip("loader",-100);
    _root.loader.loadMovie(_root.portfoliosection+".swf");
    frame 2:
    =========
    Code:
    total_bytes = _root.loader.getBytesTotal();
    KBoutput = (Math.round((total_bytes / 1024) * 1000) / 1000 + " Kb");
    loaded_bytes = _root.loader.getBytesLoaded();
    remaining_bytes = (total_bytes-loaded_bytes);
    percent_done = (((loaded_bytes/total_bytes)*100) + "% Loaded");
    pbar.gotoAndStop(percent_done);
    frame 3:
    =========
    Code:
    if (loaded_bytes >= total_bytes) {
     stop();
     }
     else {
     gotoAndPlay(20);
    }
    Does someone know how to do a proper preload with external swfs?

  2. #2
    Web Genius
    Join Date
    Nov 2001
    Location
    Canada
    Posts
    708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by djh
    I'm seriously getting my butt kicked in with this, please help!
    I'm trying to:
    1) load external swf into a new mc created using createEmptyMovieClip
    2) show size and loaded size of the external swf using getBytesTotal() and getBytesLoaded()
    3) display a progress bar based on bytes loaded
    Now, I presume one can do this a couple of different ways. You can build the preload into the external swf itself (I have tried this but had problems - the swf wouldn't display until it was mostly or fully loaded, so the progress bar wouldn't be seen...) or, I would think you can do it the way I'm trying here...
    From my main movie, i have three frames:

    frame 1:
    ==========
    Code:
    _root.createEmptyMovieClip("loader",-100);
    _root.loader.loadMovie(_root.portfoliosection+".swf" );
    frame 2:
    =========
    Code:
    total_bytes = _root.loader.getBytesTotal();
    KBoutput = (Math.round((total_bytes / 1024) * 1000) / 1000 + " Kb" );
    loaded_bytes = _root.loader.getBytesLoaded();
    remaining_bytes = (total_bytes-loaded_bytes);
    percent_done = (((loaded_bytes/total_bytes)*100) + "% Loaded" );
    pbar.gotoAndStop(percent_done);
    frame 3:
    =========
    Code:
    if (loaded_bytes >= total_bytes) {
    stop();
    }
    else {
    gotoAndPlay(20);
    }
    Does someone know how to do a proper preload with external swfs?
    Hey Dave,

    I was faced with the same problem recently as well. I managed to get mine working after tons of trial and error attempts!

    (see site - www.steveleggett.com for example)

    It looks as if you're trying to make a dynamic loading function correct?
    _root.loader.loadMovie(_root.portfoliosection+".swf" );
    Where portfoliosection is a variable?


    I had to use mine by levels to get it working properly - target the level.
    I also found that if the external swf was already loaded into memory/cache it wouldn't even use the preloader - so it wouldn't show 100%.... it would appear blank (eg 0% loaded when it was fully loaded) and then just show the page.

    The problem with Flash is that if you can't see the full working .fla it's hard to troubleshoot.


Bookmarks

Posting Permissions

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