A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: stop soundloop

  1. #1
    Senior Member
    Join Date
    Oct 2002
    Location
    belgium
    Posts
    611

    stop soundloop

    In my main swf sound is loaded into level1.When hitting but1 or 2 ... the sound is replaced by another soundloop in level1.But in the main swf I want to have a button that prevents all soundloops from playing.How do this.Like I said the sounds are loaded when hitting one off the buttons.The sound on/off button should prevent this.

    Btw this is the code used on the buttons to load sound.

    on(release){
    _level1.unloadMovie(); // empty old song from level 1
    loadMovieNum("soundloop1.swf",1); // load new song in level 1
    }

    Big thx in advance

  2. #2
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    just like the play button except only unload sound, dont load.

    Code:
    on(release){
       _level1.unloadMovie();
    }

  3. #3
    Senior Member
    Join Date
    Oct 2002
    Location
    belgium
    Posts
    611
    It's not really what I'm looking for.

    The 4 buttons on my main file load sound into level1 on release.The sound button placed on the same swf.The main swf should prevent from playing the current sound that takes place(sound level1).This works with the code you gave.But when I hit one of the 4 buttons it tells again to load sound into level1.

    so when the sound button is hit it should prevent at all time to load sound into level 1.Tell me how I can do this.Or if you have another sugestion that whill make this work.

    Hope you can help out.Grtzz

  4. #4
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    I do not understand your post.

    if you want to stop sounds, you use stopAllSounds() or unload an external SWF containing sounds.

    if you want to prevent a button from doing something, place an if then statement in the button.

    ex.
    Code:
    on(release){
      if(some condition is true){
          do somethig;
      } else {
          do something else;
      }
    }

  5. #5
    Senior Member
    Join Date
    Oct 2002
    Location
    belgium
    Posts
    611
    I'll try to explain it better.
    In the main swf where the navigation is stored are 4 buttons(about,information,portfolio,contact)

    These buttons have this code on:
    on(release){
    _level1.unloadMovie(); // empty old song from level 1
    loadMovieNum("soundloop1.swf",1); // load new song in level 1
    }

    So when hitting but1,2,3 or 4 a soundloop stored in an external swf start to play.

    On the main swf I also want to ad a sound on/off button.

    >if the main swf is loaded the external swf gets loaded into level1.So hitting the stop button should stop sound.
    >When I hit button contact for instance(4 buttons) sound gets unloaded into level 1, a new soundloop gets stored into level 1.
    By hitting the sound on/off button sound should stop.

    But here's the real problem.Say you hit the sound on/off button sound stops but when hitting one of the 4 buttons(contact,...)like U see in the script sound gets loaded.This should not happen when the sound on/off button is hit.

    I gues my sound should function like this site:
    http://12.106.77.134/
    if the soundloops are external swf's,mute sound button in the main swf,the navigationbuttons load in sound(external swf) then it would be similar to my situation.

    So how can I get this information in a if statement.How code this.
    I 'm not that great at scripting so pleace if you could help out on this.Big thx in advance.

  6. #6
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    I read this as "When the sound on/off button is in the off state it should prevent buttons 1 - 4 from loading sounds".

    the on/off button will set a variable to true or false. Then use an if then statement in buttons 1 - 4 to check variable.

    ex.

    Code:
    // on/off button
    on(release){
       // if _root.soundoff does not exist set it to true for first click
       // otherwise set it to false if true and true if false for subsequent clicks
       _root.soundoff = (!_root.soundoff);
    }
    
    // song 1 button
    on(release){
       if(!_root.soundoff){
          // code to load song
       }
    }
    Last edited by hp3; 04-24-2003 at 08:51 AM.

  7. #7
    Senior Member
    Join Date
    Oct 2002
    Location
    belgium
    Posts
    611
    Hi hp3,

    Thx for the response,but I'm still not there.Like I mentianed earliar sound is loaded in level1.I'm not that big a scripter but _root is the main file so ...Yes,the 4 buttons should prevent loading sound into level1(external swf) when the sound button is hit.(the off sound state.

    Here's the code you gave that I copied,maybe I forgot something
    You can change the code on this for my situation.Really need this to work.Big thx in advance.

    Here ya,

    // on/off button
    on(release){
    // if _root.soundoff does not exist set it to true for first click
    // otherwise set it to false if true and true if false for subsequent clicks
    _root.soundoff = (!_root.soundoff);
    }

    // song 1 button
    on(release){
    if(!_root.soundoff){
    // code to load song
    }
    }

  8. #8
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    I've done all I can do, maybe someone else can help you at this point. Hopefully someone else can help you further or you can ask general ActionScript related questions in the ActionScript forum.

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