A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Preload Sound Object Problem

  1. #1
    Member
    Join Date
    Jun 2001
    Posts
    43

    Preload Sound Object Problem

    Hey gurus. Having a problem with a preloader for a sound object movie. Basically I'm calling up a preloader to load in an MC (clip holder) in my main movie.

    The preloader loads fine in the MC (clip holder) but then the file it loads up places the SWF in the default location (top left of movie). How do I get the loader and the movie it calls up to play inside the MC (clip holder).

    The MC (clip holder) has an instance "holder"

    This is the main action from the frame with the clip holder in my main movie:
    loadMovie("swf/loaddemo.swf", "holder");
    // loaddemo.swf is the external movie I'm calling up in a SWF folder


    These are the actions I have in my loading movie (loaddemo.swf):

    onClipEvent (load) {
    loadMovieNum("swf/demo.swf", 1);
    }
    onClipEvent (enterFrame) {
    percentloaded = Math.floor((_level1.getBytesLoaded()/_level1.getBytesTotal())*100);
    if (percentloaded == 100 && !initialize) {
    _level1.mysound();
    initialize = true;
    _visible = false;
    }
    }

    The problem is the preloader loads the new movie (demo.swf) onto level 1 in the main movie in the top left corner (not inside my clip holder MC). It seems logical that my problem is because it's loading onto level 1. But if I play with that number, my preloader doesn't work. Any thoughts?
    Thank you.

  2. #2
    general rule bender Gloomycus's Avatar
    Join Date
    Nov 2000
    Location
    ontario canada
    Posts
    1,538
    I'm sorry, but I'm totally confused with what you are saying.

  3. #3
    [sleep.less.ness] euphoricGenius's Avatar
    Join Date
    Jan 2003
    Location
    insomnia
    Posts
    344

    Re: Preload Sound Object Problem

    Originally posted by beachin

    Any thoughts?

    explain it clearer eG
     Beware Of Programmers Who Carry A Screwdriver

  4. #4
    Member
    Join Date
    Jun 2001
    Posts
    43

    load sound object > revise

    Sorry. It was kind of late last night/this morning. Let me try and be clearer:

    I have a main movie (webRH4.fla) that has an Empty MC to hold a loaded external file.

    The external file is actually two files (one calling up the other) from a subfolder (swf). My main problem is this is the first time I've worked with preloading a sound object. So I built the preloader from one of the tutorials to preload the external SWF file. I get the preloader to load fine (swf/loaddemo.swf). But when it loads the sound file (swf/demo.swf) it doesn't load it in my clip holder on the main movie. It loads it on top of the main movie in level 1 at the default top left corner. I realize that is what my code is telling it do, but I don't how to adjust the code in the (loaddemo.fla) file to load the sound file (demo.fla) in the clip holder on the main movie.

    Here are the source files of what I'm trying to do:
    http://portfoliodisc.com/site/files/sitetest.zip

    When you click on the first button (demo), it jumps to the label to start the external load. I hope the source files shed a little light on what I'm trying to do. And as always, I appreciate your help.

    Thanks.

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Go to this site
    http://www.flashkit.com/board/showth...hreadid=469151
    You can download the files, which contain a preloader component for sounds. Check the actionscript inside. Although it is xml based you can see how it is done using movieclips. Sorry I don't know my scripts by heart.
    - The right of the People to create Flash movies shall not be infringed. -

  6. #6
    Member
    Join Date
    Jun 2001
    Posts
    43

    sound object preloader

    Thanks cancerinform. That is a great MP3 player. I'll have to keep that one in the vault for a music based site. But I'm looking for more of an actionscript mechanic on this one. If any of you gurus have any thoughts based on my query and source files, I would appreciate it.

    thank you.

  7. #7
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Try this: In your childmovie put this script.
    PHP Code:
    function loadMySound(){
       
    _root.holder.createEmptyMovieClip("clipHolder",1);
       
    mySound = new Sound("clipHolder");
       
    mySound.onLoad = function(success){
          if(
    success){
             
    trace("loaded");
             
    checkLoading();
          }else{
             
    trace("not loaded");
          }
       }
       
    mySound.loadSound("soundfile.mp3",false);
    }

    function 
    checkLoading(){
       
    this.onEnterFrame = function(){
          var 
    lBytes mySound.getBytesLoaded();
          var 
    tBytes mySound.getBytesTotal();
          var 
    rBytes = (lBytes/(tBytes/100));
          
    progressBar._xscale rBytes;
          if (
    rBytes >= 100){
              
    _root.goToAndPlay("frameName");
          }
       }

    You can also try to put checkLoading(); after mySound.loadSound

    Regarding the mp3player there are still some minor bugs. I will soon put the final version on.
    - The right of the People to create Flash movies shall not be infringed. -

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