Sound object wont start unless if pressed with button...
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Sound object wont start unless if pressed with button...

  1. #1
    Senior Member
    Join Date
    Feb 2004
    Posts
    133

    Sound object wont start unless if pressed with button...

    Hi guys,

    So i am building a web-site and wanted to put a small sound control system onto it. I mean one looping song with Play, Stop and volume controls. Ive managed to do that many times for CD-ROM presentations but now that I want to do it on a web-site it wont work! Heres what I am doing...

    On the second frame of the movie (on the first one Ive got my preloader):

    som = new Sound();
    som.loadSound("mp3/ambient.mp3", false)
    var vol = 70;
    _root.onEnterFrame = function() {
    som.setVolume(vol);
    vol_t.text = vol;
    }
    som.start(som.pausa, 9999);
    stop();
    Besides that, Ive put a button on the same frame with the following code:

    on (release) {
    som.stop();
    som.pausa = 0;
    if (som.pausa != null) {
    som.start(som.pausa, 9999);
    } else {
    som.start(0, 9999);
    }
    }
    Unfortunately, once the site opens the song wont play at all... In the other hand, If I press this button, the song will start. That behavior tells me that the movie IS finding and loading the MP3 file, but it is not starting it unless told so by the button.

    And just to make things a little bit more awkward, that behavior only happens when I test the movie in its remote server. If I test the movie in my PC locally there wont be any problems at all...

    Thank you for any help.

    Regards

  2. #2
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    It sounds as though your trying to start the sound before it has entirely loaded. Locally, it will probably load fast enough to catch the start method, but online, if the start action is called before the file completely loads, it will be ignored. Maybe use an onLoad function to determine when the sound has loaded and then start it...

    code:

    mySound.onLoad=function(success){
    if(!success){
    trace("Failed to load");
    }else{
    mySound.start();
    }
    }


  3. #3
    FK Slacker
    Join Date
    Jun 2000
    Location
    vancouver
    Posts
    3,208
    The problem with this is that you are trying to start the sound before it has loaded...

    code:

    som = new Sound();
    som.loadSound("mp3/ambient.mp3", false)
    var vol = 70;
    _root.onEnterFrame = function() {
    som.setVolume(vol);
    vol_t.text = vol;
    }
    som.start(som.pausa, 9999);
    stop();


    You should create a Sound.onLoad handler which triggers the start action when the sound file has fully loaded:
    code:

    som = new Sound();
    som.loadSound("mp3/ambient.mp3", false)
    var vol = 70;

    _root.onEnterFrame = function() {
    som.setVolume(vol);
    vol_t.text = vol;
    }

    som.onLoad=function(){
    som.start(som.pausa, 9999);
    }
    stop();



    K.

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

Poll by Flashkit.com