Results 1 to 3 of 3

Thread: background sounds

  1. #1
    Join Date
    Feb 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default background sounds

    i am having a problem with importing sound and having it play on ONLY my main page (frame 1). frame 2 through the rest of them are linked to from the main page, but i dont want the sound playing on these pages (frames)

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Put the sound HTML in the frame page, not the main page. That way it will only play in the frame, also if you're trying to use bgsound, don't. Use embed:
    Code:
    <embed src="path/to/mymusic.mp3" hidden="true" autoplay="true">

    //EDIT: Ooops... I didn't know this was in the flash section, thought it was HTML. Sorry, but our Flash expert has left temporarily, and not many others know flash that well.
    - Mike

  3. #3
    Join Date
    Apr 2007
    Location
    Phoenix, AZ
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    If you want to have exact control over a sound, you should use the Sound object. You can either load a sound from a file, or attach a sound that is in the library. Once you have the sound defined as a variable, you can control it with the Sound.start() and Sound.stop() methods as needed.

    For example, on Frame 1:
    Code:
    if (my_sound == undefined){
         var my_sound:Sound = new Sound();
         my_sound.loadSound("song1.mp3", false);  //The second parameter says whether this is a streaming sound or not. 
                                                  //"false" will make the entire sound load before it starts playing
    } else {
         my_sound.start();
    }
    This will either load the sound into the object, or if it's already loaded, will start playing it. Then on all other frames, you can add

    Code:
    my_sound.stop();
    The documentation has a lot of other good info about the Sound class too.

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
  •