A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Controling Sound

  1. #1
    not'n' wrong with hat'n' sushi iHATEsushi's Avatar
    Join Date
    May 2006
    Location
    Ontario
    Posts
    132

    Controling Sound

    Ok, I am thinking that this is something so simple and that I am not able to piece the logic together because my brain is dead.

    Here is my Issue:

    I am making a very simple Flash game using Flash vs. 8.

    When you click on one button it takes you to the intro screen, then to the character selection screen, to intro level one, then to level one and so on.

    Anyhow, I have a different song or (sound loop/FX) for each seperate section.

    Whats happening is that I tried to attach the song to the movie clip by going inside the movie clip and looping the sound from there so that it will continue playing while the user is on that screen.

    What I have run into is that as soon as I click to a different section the song from the previous section is still playing. So I tried every section from Event to Start, to Stream to try and over come this issue and none of it worked.

    So now I am thinking I need some Actionscript to control when the music starts and stops. I do not know how to code this.

    Can anyone help?

    I tried looking in Chapter 16 of Flash 8 Actionscript but all it talks about is attaching sound to movie clips but not to the actual scene. Is there a way to control the sound from the file? to start and stop when I need it to like when the user clicks and it moves to whatever keyframe, then stop and play this?

    Any and all help would be great. If you need some clarrification please let me know.. Thanks!

  2. #2
    Modulator Katnap Kaos's Avatar
    Join Date
    Nov 2003
    Location
    A shoebox outside of SM Megamall
    Posts
    149
    Is the intro screen/ character select e.t.c. done in frames or loadMovie?

    If it is done in frames, you can just declare a variable to hold and play the music each frame:

    example:
    Code:
    //Frame 1
    var music_loop:Sound;
    music_loop.attachSound("loop1.wav");
    music_loop.start(0,999);
    
    //Frame 2
    music_loop.stop();
    music_loop.attachSound("loop2.wav");
    music_loop.start(0,999);
    
    //Frame 3
    e.t.c...
    And in your library, you just need to linkage the music loops according to what you've set the identifiers (or the other way around as logic would have it ^_^;; ).
    As a Gamer, you play by the rules.
    As a Programmer, you play as God.

  3. #3
    Modulator Katnap Kaos's Avatar
    Join Date
    Nov 2003
    Location
    A shoebox outside of SM Megamall
    Posts
    149
    Whoops...just tested it...

    Modified to:

    Code:
    //Frame 1
    music_loop.stop()
    var music_loop:Sound = new Sound(_root);
    music_loop.attachSound("loop1.wav");
    music_loop.start(0,999);
    
    //Frame 2
    music_loop.stop();
    music_loop.attachSound("loop2.wav");
    music_loop.start(0,999);
    
    //Frame 3
    e.t.c...
    As a Gamer, you play by the rules.
    As a Programmer, you play as God.

  4. #4
    not'n' wrong with hat'n' sushi iHATEsushi's Avatar
    Join Date
    May 2006
    Location
    Ontario
    Posts
    132
    You are an angel sent down from heaven. I would send you flowers if I could so I will send you a hug instead

    You have taken eons of frustration off of me. Many thank you's...

    I am still new to the Actionscript side of things, and am trying to build different things to learn how they work together. I still havent quite understood the logic, but am slowly learning.


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