A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Preloading Sound

  1. #1
    Member
    Join Date
    Sep 2004
    Location
    Brighton/UK
    Posts
    30

    Preloading Sound

    I am almost at the point of of throwing my computer off the roof of my flat

    I have made my little 'ambiance swf' and defined a sound object in using the old faithful method of...

    firstSound = new Sound(this);
    firstSound.attachSound("sound01");

    _root.firstSound.start();

    in frame 1 of the main timeline I have used my stock preloader which is coded as follows:

    total_bytes = _root.getBytesTotal();
    loaded_bytes = _root.getBytesLoaded();
    remaining_bytes = total_bytes-loaded_bytes;
    percent_done = int((loaded_bytes/total_bytes)*100);
    bar.gotoAndStop(percent_done);
    ifFrameLoaded ("loader", 30) {
    gotoAndPlay(3);
    }

    This code works on all my other movies but not this one. Is there anybody out there who can help. Maybe even take a look at my fla.

    Regards.

  2. #2
    Member
    Join Date
    Sep 2004
    Location
    Brighton/UK
    Posts
    30
    here is the link to my web page:

    www.poipoi.info/mike/index.html

    and here is the pesky fla...

  3. #3
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    if your sound is in the same SWF as the load progress code then review FAQ #3.

    if you are attempting to display load progress of an external SWF, then you will need to know the correct target path to the SWF and include this in your code, instead of _root.

  4. #4
    Member
    Join Date
    Sep 2004
    Location
    Brighton/UK
    Posts
    30
    The load progress code is on frame1 and the sound object is on frame 3 - all in the same swf...

    What am I reviewing in FAQ#3 I don't follow.

    Cheers

  5. #5
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    The default behavior of Flash is to load attached sounds before anything else in the movie.

    It does not matter where in the movie you create your sound object, Flash will load the sound before it loads frame 1.

    Therefore the sound will load before Flash executes your load progress message, making your load progress message useless.

    A2 under FAQ #3 explains how to work around this problem by unchecking the "export in first frame" box.

  6. #6
    Member
    Join Date
    Sep 2004
    Location
    Brighton/UK
    Posts
    30
    I was looking in the wrong FAQ (no wonder it made no sense)

    Ok. I was looking at your tutorial and I'm going to have to be really simple now cos I'm still a bit confused. My ambiance.swf is an external swf loaded into my main template. I have unchecked export in first frame as you pointed out but now when I export the swf the sound doesn't load at all.

    I'm sure i'm being really dumb but how can I resolve this?

    I apreciate your help.

  7. #7
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    if you are loading an external SWF the noraml approach is to load it into a movie clip in the main movie and track load progress from the main movie.

    So just put the sound object in the external SWF and put the load progress code in the main movie.

    // external SWF
    mysound = new Sound(this);
    mysound.attachSound("linkage");

    // main SWF
    loadermc.loadMovie("urlto.swf");
    // load progress code.

    If you need general help with load progress messages and external SWF you might follow up in the ActionScript forum.

  8. #8
    Member
    Join Date
    Sep 2004
    Location
    Brighton/UK
    Posts
    30
    ok thanks, thats what i was confused about.

    one last quick one then I'll stop bugging you.

    So If I put the load progress code into the main template will that affect the way that my initial content is loaded or will that play as normal with the sound loader visible in say the bottom corner?

    Thanks

  9. #9
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    loading external SWF, and displaying a corresponding load progress message should not interfere with playback of content you have already loaded. This assumes you set up the load progress message so that it runs independantly of the rest of the main SWF.

    Loading external SWF while progressively loading/playing the main SWF might interfere with the main SWF playback because there might not be enough bandwidth for both.

    Safest thing to do is to wait until Flash finsihes loading main SWF content before attempting to load external SWF.

  10. #10
    Member
    Join Date
    Sep 2004
    Location
    Brighton/UK
    Posts
    30
    Ok thanks for the advice mate

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