A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: How do you make it so you can only have one audio-file playing?

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    3

    Unhappy How do you make it so you can only have one audio-file playing?

    I'm making a soundboard/Ishkur guide styled-flash and need to make it so you can only have ONE sound playing. If you click on a different button it quits the previous audio. And while I have your attention, I also need to know how to make it so clicking on one of the buttons makes text appear on the bottom right, and clicking on another gets rid of the previous text. To get an idea of what I mean, look at this :
    http://techno.org/electronic-music-guide/
    Last edited by Sphotof; 01-09-2013 at 06:48 PM.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    A very basic way can be like this
    PHP Code:
    var MySound = new Sound();
    Button1.onPress = function()
    {
        
    MySound.stop();
        
    MySound.loadSound("Song1.mp3",true);
        
    MyText.text "Song 1 playing";
    };
    Button2.onPress = function()
    {
        
    MySound.stop();
        
    MySound.loadSound("Song2.mp3",true);
        
    MyText.text "Song 2 playing";
    };
    Button3.onPress = function()
    {
        
    MySound.stop();
        
    MyText.text "No song playing";
    }; 
    having the songs in the same directory as the swf

    or a similar simple way
    PHP Code:
    NoSong "No song playing";
    Song1 "Song1.mp3";
    Song2 "Song2.mp3";

    var 
    MySound = new Sound();
    Button1.onPress = function()
    {
        
    MySound.stop();
        
    MySound.loadSound(Song1,true);
        
    MyText.text Song1;
    };
    Button2.onPress = function()
    {
        
    MySound.stop();
        
    MySound.loadSound(Song2,true);
        
    MyText.text Song2;
    };
    Button3.onPress = function()
    {
        
    MySound.stop();
        
    MyText.text NoSong;
    }; 
    Last edited by fruitbeard; 01-11-2013 at 07:04 AM.

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