Making a button play sound

     Okay, i have been working on flash in school, and the school upgraded from flash MX to flash CS5, i have then gone to make my project in AS3, however, it is very diffrent from AS2
     My problem, is, all i want is a button to play a song from the libray (not from a URL on the internet like the code snippet) and my ICT teachers have no idea how to use AS3. I also need is a play, stop and pause button, and a volume control slider, i CAN do all these on AS2, i infact have it set up (but without a pause button) but, i cannot do this in AS3 and i need it done bady, can anyone explain simplay how? all guides i can find use AS2

Well, thank you for the help, although i havent followed it completly it has helped me get started, so far i have programed a working play and stop button, the volume slider is still beyond me, my codeing sofar is;
play_btn.addEventListener(MouseEvent.CLICK, onClickPlay);
function onClickPlay(e:MouseEvent):void{
myChannel = mySound.play();
var mySound:Sound = new MP3_1();
var myChannel:SoundChannel = new SoundChannel();
stop_btn.addEventListener(MouseEvent.CLICK, onClickStop);
function onClickStop(e:MouseEvent):void{
myChannel.stop();
Any suggestions on how to make a Slider adjust the volume levels, using a compent slider

Similar Messages

  • Play button for sound files in the browser..?

    I wonder if there's a setting (or something) in Finder so it displays a play button for sound files the same way as it does for video files?
    -- peer

    App Producks wrote:
    that sounds broken, sad no one replied you two years ago .
    Actually is sounds as if it was working correctly. Mute only mutes notifications (phone rings, text, email, etc). What is less explicable is why you felt the need to resurrect this thread.

  • Making buttons play music?

    I want to make on button play a piece of music and another one to stop the music. I manage to make buttons work for playing frames in the timeline, but how do I make the buttons play the music and stop it? I tried this http://www.flash-here.com/tutorials/flash_play_sound.html but I guess this is not action script 3.0 which I am using because it does not work...

    Thanks for the tutorial, but I think it is too advanced for my needs. My knowledge inte action script are still on a very low level so I am trying to learn by doing. This is what I have managed to do so far.
    stop();
    var snd:Sound = new popeye();
    radio_on_btn.addEventListener (MouseEvent.CLICK, play_radio_fkn);
    function play_radio_fkn (event:MouseEvent):void {
    snd.play();
    radio_off_btn.addEventListener (MouseEvent.CLICK, stop_radio_fkn);
    function stop_radio_fkn (event:MouseEvent):void {
    snd.close();
    But using close() does not work, the error message says there is no stream to close. The on-button works though. I am guessing I need a soundChannel-something. But I have a problem with the syntax and I don't know how to fit it in...

  • Find my iphone play sound "ok" button not working.

    Okay, I was derping around with my ipod, then clicked play sound. i went to my ipod and checked it, it said find my ipod play sound or something. i tried clicking okay but it wouldn't do anything. i had to reset it so i did. was there a better solution? I just wanna know now before i mess up again

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings      
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up                             
    - Restore to factory settings/new iOS device.
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar          

  • Help with playing sound in applications

    im new to java and i was practicing playing sound in a swing application but the problem is that when i press the play button no sound is played...here is my code
    import javax.swing.*;
    import java.applet.AudioClip;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.io.File;
    public class JukeBox extends JFrame {
        private JLabel label;
        private JPanel panel, buttonPanel;
        private JComboBox playList;
        private JButton play, stop;
        private URL url1, url2, url3, url4, url5, url6;
        private AudioClip[] musicList;
        private AudioClip current ;
        public JukeBox() {
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setSize(500, 120);
            setLocation(50, 50);
            setTitle("JAVA JukeBox");
            url1 = url2 = url3 = url4 = url5 = url6 = null;
            current = null;
            try {
                url1 = new URL("file", "localhost", "C:\\Documents and Settings\\KADA\\IdeaProjects\\Sound\\bottle-open.wav");
                url2 = new URL("file", "localhost", "C:\\Documents and Settings\\KADA\\IdeaProjects\\Sound\\BP2.mp3");
                url3 = new URL("file", "localhost", "C:\\Documents and Settings\\KADA\\IdeaProjects\\Sound\\fhm.aiff");
                url4 = new URL("file", "localhost", "C:\\Documents and Settings\\KADA\\IdeaProjects\\Sound\\jungle.rmf");
                url5 = new URL("file", "localhost", "C:\\Documents and Settings\\KADA\\IdeaProjects\\Sound\\spacemusic.au");
                url6 = new URL("file", "localhost", "C:\\Documents and Settings\\KADA\\IdeaProjects\\Sound\\trippygaia.mid");
            } catch (MalformedURLException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            musicList = new AudioClip[7];
            musicList[0] = null;
            musicList[1] = JApplet.newAudioClip(url1);
            musicList[2] = JApplet.newAudioClip(url2);
            musicList[3] = JApplet.newAudioClip(url3);
            musicList[4] = JApplet.newAudioClip(url4);
            musicList[5] = JApplet.newAudioClip(url5);
            musicList[6] = JApplet.newAudioClip(url6);
            label = new JLabel("JAVA JukeBox", JLabel.CENTER);
            String[] musicList = {"select a track..."
                    , "bottle open"
                    , "bitch please II"
                    , "flutte, harmonica, mambo"
                    , "jungle"
                    , "spacemusic"
                    , "trippygaia"};
            playList = new JComboBox(musicList);
            playList.addActionListener(new ListListener());
            play = new JButton("Play");
            play.setActionCommand("play");
            play.addActionListener(new ButtonListener());
            stop = new JButton("Stop");
            stop.addActionListener(new ButtonListener());
            buttonPanel = new JPanel();
            buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
            buttonPanel.add(play);
            buttonPanel.add(stop);
            panel = new JPanel();
            panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
            panel.add(label);
            panel.add(Box.createRigidArea(new Dimension(0, 5)));
            panel.add(playList);
            panel.add(Box.createRigidArea(new Dimension(0, 5)));
            panel.add(buttonPanel);
            getContentPane().add(panel);
        private class ButtonListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                if(current != null){
                    current.stop();
                if(e.getActionCommand().equalsIgnoreCase("play")){
                    if(current != null){
                        current.play();
        private class ListListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                if (current != null) {
                    current.stop();
                current = musicList[playList.getSelectedIndex()];
        public static void main(String[] args) {
            setDefaultLookAndFeelDecorated(true);
            JukeBox jb = new JukeBox();
            jb.setVisible(true);
            jb.setResizable(false);
    }can u please tell me whats wrong with my code coz i cant hear no sound when i press the play button and can u please tell me why i cant simply put the file name in the URL instead of the complete path although the files are in the same directory of the source code and can i play mp3 using this little program ???
    plz help...im a newbie so plz explain as much as u can...

    After
    musicList = new AudioClip[7];
            musicList[0] = null;
            musicList[1] = JApplet.newAudioClip(url1);
            musicList[2] = JApplet.newAudioClip(url2);
            musicList[3] = JApplet.newAudioClip(url3);
            musicList[4] = JApplet.newAudioClip(url4);
            musicList[5] = JApplet.newAudioClip(url5);
            musicList[6] = JApplet.newAudioClip(url6);initialise the variable current with
    current = musicList[1];or similar because the AudioClip current always == null in your code so your listener blocks don`t execute.
    regards

  • How do I tell Apple to fix their software like apps that play sound even though the sound is turned off and not being able to disable features you hate like game center

    Apple is suppose to be the pinnacle of usability and, yet, I want to throw my new IPhone 4s as far as I can and watch is smash into a million pieces on concrete. Seriously, I've already got three things that irritate the **** out of me. First, there are Apple apps that insist on playing sound even though the sound is turned off. If I flick a switch to turn the sound off, I want the sound off!!!! Second, if I do not want a totally unnecessary feature like Game Center, I should be able to disable it. I completed most of the Angry Bird levels with 2 or 3 stars and now I have to start over from square one. Maybe, this happened when I upgraded to the 4s but it sure seemed to happen when I joined Game Center. Tomorrow, I am going to reset my 4s to factory defaults to try to get rid of my Game Center account. I don't want Game Center! I do need Game Center! I hate Game Center! Finally, I had an alarm go off to wake me up and there was a Snooze button but no button to turn the alarm off. I flicked the slider to access the main screen expecting to see something to turn the alarm off but there was nothing. The alarm just kept alarming. I had to warm boot my IPhone to shut the alarm off! Really, Apple!!!!

    The sound is turned off. Only, some Apple apps like YouTube and Siri make sound when the sound is turned off. It is very embarrassing when this happens at work. My question was how do I tell Apple to fix this?
    Turning off game center does not work. The games just prompt me to sign in when they are started.I have tried everything I can find online to stop this behavior. It is annoying and should not happen. My question was how do I tell Apple to fix this?
    The alarm went off. There was a green thing that looked like a button but pressing it did nothing. There was a red button that said snooze. I did not want to snooze. I wanted to turn the alarm off. I slid the bar to unlock the phone and there were no running apps with a button to press. The alarm just keep running. I have not had this problem since it first occurred. The alarm now shuts off when I just unlock the phone. It may have happened because I had another alarm app running. The two may have interfered with each other. I would like to tell Apple about it.
    It also annoys me that the button that closes apps leaves the phone app running. If I press on a number at 6:00 AM to get information about who called me, the phone automatically dials the person back and my natural reaction is to press on the button to close the phone app but the phone keeps dialing this person at 6:00 AM. It is a bad design. I would like to tell Apple about it.
    Finally, I looked all over Apple's site to try to find someplace I could send them a polite message to let them know that I was not happy with these "features" but could not find anything. It is extremely frustrating to have issues with a product and not being able to tell the manufacturer about it. So, you grow up!.
    When trying to fix the Game Center issue, I saw a link someone posted to report issues with the IPad to Apple. The answer I am looking for is where is the link to report issues with the IPhone.

  • So my I phone 4s volume has decided to pack  allowing only my phone to make sounds when I have an incoming call, I can also here fine using facetime and receiving calls. YouTube, soundcloud, any of I players will no longer play sound. I've restored the ph

    So my I phone 4s volume has decided to pack  allowing only my phone to make sounds when I have an incoming call, I can also here fine using facetime and receiving calls. YouTube, soundcloud, any of I players will no longer play sound. I've restored the phone using iTunes on my laptop and checked all the volumes are turned up and the button at the left hand Side of the phone is in the correct position.

    Try inserting and re-inserting your headphones 7 or 8 times. Also try cleaning out the headphone jack in case of debris that might be interfering with the connection/disconnection.

  • IPhone no longer plays sound/music thru earphones

    My iPhone will not play any sound (music, podcasts) through my earphones.  The speakers on my iPhone work but not the earphone piece.  I have tried several earphones but none of them work.  It's as it my iPhone does not register them.  It continues to play sound via the speakers even when earphones are plugged in.  Do you think the iPhone is broken or did I do something to turn off the earphones.

    How do I check if the volume setting is on.  I thought the volume button was the same for both.
    Everything was working fine on my iPhone yesterday and then suddenly today the earphones don't work.
    I wonder how much a new earphone jack costs.

  • My ipad is no longer playing sounds on some games

    My ipad is not playing sounds for most of my games but for apps like netflix it does. i have checked settings and vol is all the way up. i also noticed that when i slide the bar to unlock after it goes into rest mode i don't hear the clicking sound anymore. anyone have anything like this happen? i tried shutting it down and started it back up its still not working

    You have system sounds muted.
    If you lose sounds for keyboard clicks, games or other apps, email notifications and other notifications, system sounds may have been muted.
    System sounds can be muted and controlled two different ways. The screen lock rotation can be controlled in the same manner as well.
    Settings>General>Use Side Switch to: Mute System sounds. If this option is selected, the switch on the side of the iPad above the volume rocker will mute system sounds.
    If you choose Lock Screen Rotation, then the switch locks the screen. If the screen is locked, you will see a lock icon in the upper right corner next to the battery indicator gauge.
    If you have the side switch set to lock screen rotation then the system sound control is in the task bar. Double tap the home button and in the task bar at the bottom, swipe all the way to the right. The speaker icon is all the way to the left. Tap on it and system sounds will return.
    If you have the side switch set to mute system sounds, then the screen lock rotation can be accessed via the task bar in the same manner as described above.
    This support article from Apple explains how the side switch works.
    http://support.apple.com/kb/HT4085

  • How do you open/play a .wav file (music file) without play sound file .vi

    I am having big problems to create a music background for my project. I am newbie using labview and maybe my questions is not so dificult to solve (I hope so)
    I was using play sound file vi but the problem is that I dont want the music file start automatically. I wanna control the start time using a button. I tried include a sound output stop but when the app start and I add more wav files in my vi, the sound file start, then stop abruptally because the stop vi and the everything is normal. I would like to eliminate that error.
    Someone have any idea, maybe using open file or another way. 
    Thanks in advance
    I add a screenshot of my vi and also the vi in this post
    Attachments:
    test sound.vi ‏11 KB

    I leave an example that can provide, use it in your program
    Atom
    Certified LabVIEW Associate Developer
    Attachments:
    playsound.zip ‏58 KB

  • Dv6 Only plays Sound out of the built in speakers if headphones are plugged in ...please help

    My Pavillon Dv6 Only plays Sound out of the built in speakers if headphones are plugged in. It plays sound from both when there plugged in. Please hep me.

    Step 1:
    In troublshooting the problem you may follow the steps provided below.
      a. Click Start, type Sound in the Start Search box. 
      b. Click Sound in the search results at the top of the Start menu. 
      c. Click the Playback tab. Notice the check mark next to the default device. For most users,the default device is speaker, change it to headphones. Make sure that your audio settings are configured as expected.
    Step 2:
    On the Playback tab, select the playback device, click Properties, click the Advanced tab, and make sure that the Default Format is set to the value that you expect. When you finish, close this window to return to the previous window.
    Step 3:
    On the Playback tab, select the playback device, click Configure, and then make sure the configurations are set correctly.
    Method 2:
    If the issue persists then I suggest you to follow these below mentioned steps to mute all other sounds when windows detects any communications activity.
      a. Click Start, type Sound in the Start Search box. 
      b. Click Sound in the search results at the top of the Start menu. 
      c. Click the Communications tab.
      d. Click on the radio button according to your convenience, under When Windows detects communications activity.
    After performing the above steps you may check for the issue.
    For more troubleshooting you may visit this below mentioned link.
    Tips for fixing common sound problems
    http://windows.microsoft.com/en-us/windows7/Tips-for-fixing-common-sound-problems 
    Let us know how it goes!
    "I work for HP."
    ****Click the (purple thumbs up icon in the lower right corner of a post) to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    Regards
    Manjunath

  • HT201401 My iphone 4 wont play sound through the internal speaker. Will play if I hook up headphones. I have reset it, restored it, and it does the same thing.

    My iphone 4 wont play sound through the internal speaker. Will play if I hook up headphones. I have reset it, restored it, and it does the same thing. I can still hear when i make calls too. The the output button only says dock connector or apple tv.

    If the phone has ever gotten wet it may be damaged. It may also have dirt or a bent pin in the dock connector or the earphone jack. Try cleaning the dock connector and inspecting it with a magnifying glass. Try inserting and removing the earphone plug several times. If you have restored it and that did not fix the problem damage is the most likely cause.

  • Play sound in specified duration and desired file when reading data with VISA functions ?

    Hi.
    I read data with VISA read function and then I use functions like multiple for showing data on Chart. every thing is OK.
    now I want play a specified sound (like a 3s song in my desired folder) when signal amplitude cross over from specified value. then after desired time, it will be wait for new cross over from specified value and this procedure repeat again until I stop the program. 
    Data comes from MCU and it doesn't stop when system play sound and when system play sound, incoming data for this part (play sound) will be ignore them until specified expired.
    I use this VI for reading data and mentioned part which is sound part is empty and I don't know what I must done ?
    altougth I use another while loop for sound apart because I want save CPU time.
    Thanks.
    Solved!
    Go to Solution.

    I would recommend making the data type of the notifier a cluster that contains a path and a numeric (double).  The path tells the player which file to play.  The numeric is the duration.
    Now for a slightly complicated, but really neat, way to stop your second loop.  Do not use a second notifier.  Instead, send the normal notification but use Not A Path for the path in the cluster.  Your second loop can do a check for the Not A Path and stop when that is recieved.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • My ihome wont play sound

    i plug in my ipod touch and it charges but wont play music and i have it set for ipod i try it on radio and it wont play sound then either!

    Did it work before?
    Does iHome say it will work with a 4G iPod with yur iOS?
    Sometimes this helps:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings      
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up                                                 
    - Restore to factory settings/new iOS device.

  • No /dev/dsp, some programs failed to play sound

    I'm using chakra-2010.09 and there is no /dev/dsp after a default installation. Programs using phonon as backend (KDE's login music and the default music player, Bangarang) can play sound without problems. But others like vlc, flashplugin and wine cannot. Vlc just report errors about no /dev/dsp. How can this be fixed?
    Then I tried #modprobe snd_pcm_oss snd_mixer_oss snd_seq_oss, the module created /dev/dsp1. then I maked a soft link to /dev/dsp but vlc said "cannot open device /dev/dsp".
    I also tried using osspd and vlc can play sound now, but flashplugin and wine still have problems.
    Here are some of my system information:
    [admin@LenovoPC ~]$ cat /proc/asound/cards
    0 [Generic ]: HDA-Intel - HD-Audio Generic
    HD-Audio Generic at 0x90244000 irq 42
    1 [SB ]: HDA-Intel - HDA ATI SB
    HDA ATI SB at 0x90240000 irq 16
    [admin@LenovoPC ~]$ lsmod | grep snd
    snd_hda_codec_conexant 39073 1
    snd_hda_codec_hdmi 19967 1
    snd_hda_intel 19020 6
    snd_hda_codec 67097 3 snd_hda_codec_conexant,snd_hda_codec_hdmi,snd_hda_intel
    snd_hwdep 4812 1 snd_hda_codec
    snd_pcm 59717 4 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec
    snd_timer 15279 2 snd_pcm
    snd 43259 17 snd_hda_codec_conexant,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer
    soundcore 4993 1 snd
    snd_page_alloc 5805 2 snd_hda_intel,snd_pcm

    RichSelian,
    It is our policy that we only support Arch Linux.  Please take this to http://chakra-project.org/bbs/

Maybe you are looking for