dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Sound loops on/off, just in 1 button.

  1. #1
    Junior Member
    Join Date
    Oct 2003
    Posts
    9

    Sound loops on/off, just in 1 button.

    sorry , but i have to post this:

    How to make a simple on/off button for the sound loop?

    I already checked the FAQ , and the number 18 applies, however, im so n00b that i even found that explanation pretty confusing, can somebody explain me step by step how to do this the "easiest" way?

    I dont want 2 buttons (1 for ON and 1 for OFF) i just want 1 button for both actions.

    Thanks.

    PS: i also check this tutorial http://www.flashkit.com/tutorials/Au..._-71/index.php thats what i wnana do, but it also lost me at some part, specially when asking for a new movie for the sound, cant i just put the loop in 1 layer in the main timeline?

  2. #2
    Member
    Join Date
    Feb 2001
    Posts
    86
    Since you're new I'm going to do the simplest way ( no attach movie and stuff like that )

    This example assumes you have your music loop in a separate movie clip called music. Frame #1 of that move has the loop started and frame #2 has the same loop stop action.

    Then all you need to do is add this action to your button:


    on (release) {
    if (sound==1) {
    music.gotoAndStop(2 );
    sound = 0;
    } else {
    music.gotoAndStop(1 );
    sound = 1;
    }
    }

    sound variable which changes from 0 to 1 could also be reset from within your music loop. Put _root.sound =1 in frame one when music starts and _root.sound=0 in frame 2 where music stops. Actually you have to have sound=1 somewhere to initialize the whole thing, so the best way to do it is in the first frame of your music MC.

    You can apply this to other setups, just pay attention to levels and targeting of timelines.

    You could have it on the main timeline, but it's not recommended.
    You'd simply use frame one and two of the main timeline ( or 11 and 12, whatever ) to start and stop music.
    The coolest sig. is yet to come

  3. #3
    Junior Member
    Join Date
    Oct 2003
    Posts
    9
    arrrrrrrrrrrrrrgggggggggggghhhhhhhhhhhhhhh!!!!!

    Im using this tutorial : http://www.flashkit.com/tutorials/Au..._-71/more6.php

    but i dont understand this part, i think im doing somteing wrong in here:

    You'll notice I added a sound on/off button. This is a major forget me on a lot of sites now, but I think it should always be there. Just remember, not everyone has the same ears. This is a simple button that goes to a second frame in the movie. On this frame, I have assigned 2 actions. A "Stop all sounds" (to stop the music) and a "stop" command(to stop the movie). On this frame, the button's action's change to "go to & stop on frame one"(which starts the loop again. This is a very simple, but effective method for sound toggle.

  4. #4
    Junior Member
    Join Date
    Oct 2003
    Posts
    9
    OMG, OMG, OMG!!!!!!!

    i did it!!!!!!!!!!....FINALLY!!!!!!!!!

  5. #5
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    Here's an easier way:

    on(release) {
    count++;
    if (count % 2) {
    sound1.stop();
    } else {
    sound1.start(0,500);
    }
    }

  6. #6
    Senior Member
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    189
    IASKWHY, is the code you posted for a sound contained in an external movie that gets loaded that gets loaded into the main movie?

  7. #7
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,490
    It can be used for anything, toggleing sounds, movie clip timelines, just about anything. In the code I gave, the two sound1 lines, you would put the full path to the sound object, whether it's in an attached sound or one loaded from an external swf. Just target where the sound object is in those two lines.

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