Playing sound using ActionScript 3.0 (newbie)

I have a Flash animation I've created, and at the last minute we have decided to add one audio track to the background.  The problem is, I have a looping animation in the timeline, so simply inserting the audio into a layer in the timeline will not work (because it will loop as well).
Can anyone help me with how to insert just one sound file "on top" of all the animations playing using ActionScript 3.0?  I've never worked with the Sound class, and have never put audio into a Flash file besides simply importing it into a frame.
THANKS!
Jen

Worked perfectly.  Thank you thank you!
Jen

Similar Messages

  • Rollover buttons to play sound using "loadSound"

    Hi, there
    I am seeking help with the following AS2 code. The target effect: Rolling over each of the two buttons on the main stage plays different sound. The code below works. However, I need to embed it in another application (Articulate) which doesnot allow the use of "_root" and "attachSound". I was recommended to use "loadSound" instead. However, not a coding person, I am at a loss.
    Can anyone help me to change the script below to remove "_root" and "attachSound" and use "loadSound" instead? Thanks so much!
    var mySound:Sound = new Sound();
    mcButton5.onRollOver = function() {
    _root.mySound.attachSound("sound1");
    _root.mySound.start();
    var mySound:Sound = new Sound();
    mcButton6.onRollOver = function() {
    _root.mySound.attachSound("sound2");
    _root.mySound.start();

    I finally got it work, using load Sound...
    Kglad, thanks for your great help, as always!
    mySound1 = new Sound();
    mySound1.loadSound("Sound1.mp3", false);
    mcButton1.onRollOver = function() {
    mySound1.start();
    mcButton1.onRollOut = function() {
    mySound1.stop();

  • Playing sound using quicktime package?

    I'm trying to make a very simple program (actually, part of a much larger program) that can play a sound file. Nothing else needs to happen during that time, and no other sound file will be played at the same time, so hopefully I'll be able to avoid threads, mixers, and all the rest of that stuff.
    After not being able to make head or tails of all the extremely complicated tutorials on Java Sound, I finally found some very short code that allows me to play a .wav file, just like I'd want. My only concern is that it uses the quicktime package, instead of the Sound package that everyone else seems to refer to.
    In particular, it seems to be treating the sound file like a movie. Here's some source code:
    import quicktime.*;
    import quicktime.io.*;
    import quicktime.app.time.*;
    import quicktime.app.view.*;
    import quicktime.std.movies.*;
    import quicktime.std.*;
    // Lots of GUI interface stuff
        public void playFile (String fileName) {
             try {
                String soundLocation = QTFactory.findAbsolutePath(fileName).getPath();
                OpenMovieFile fileIn = OpenMovieFile.asRead (new QTFile(soundLocation));
                movie = Movie.fromFile (fileIn);
                TaskAllMovies.addMovieAndStart();
                movie.setActive(true);
                movie.setRate(1);
               } catch (IOException ioe) {
                    ioe.printStackTrace();
               } catch (QTException qte) {
                    qte.printStackTrace();
        }Does this seem to be all ok? Will the computer the program is running on need QuickTime, or is that completely different? Is this as fast as using Java Sound?
    Sorry for the possibly silly questions. Normally I'd say "I've tested it, it works, so that's all I need", but I got a little bit worried seeing "quicktime" and "movie", and wondered if this is what I really should be using.
    Thanks!

    Also-- something to think about. You may be able to
    avoid threads while the song is playing-- if you
    never want to stop it, pause it, or do *anything
    else* within the same GUI -- assuming you're using a
    GUI.
    Hope something in the above helps.In this program the user doesn't get to control the sound while it is playing. The program is an assesment of language comprehension engine for my lab. The user hits "Go", the sound plays (all 2-3 seconds of it), then the user hits "yes" or "no" depending on the sound.
    I'm only just starting to code this. Do you think it's going to need threading? I can't imagine that it ought to take more than 5-10 lines of code, but those Sound tutorials made it seem like I'd need 100.
    As for playing a "movie", that's why I was worried. Taking a deeper look, it seems like Apple's Developer website is promoting using the QuickTime package, but I haven't yet worked out how compatible it is with other file systems, and whether it's as good.
    Thanks, and any other thoughts are welcome!
    --Sam                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Play sound using web.show document

    Does anyone know if web.show_document can be used to play a .wav without displaying the media player on the screen ?

    INteresting thread, one other thing to mention is that while we are opening up Forms to the Java world, we are infact trying to maintain the 4GL pl/SQL interface we know that the Forms developers like.
    So for example, while we introduced PJC and Java Beans in earlier releases, in subsequent releases we have added packaged (FBEAN) to protect you from the nuts and bolts of Java.
    Sure, if you are writing PJC and Beans then you may already have taken the jump into the Java world but equally it could be one of the "new kids" who have grown up with Java who are writing these and all the experienced "old timers" plug it into Forms ;o) [without having to get too wet in the java pond).
    Grant                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Use actionscript to trigger independant sound loop and reset

    Hello guys,
    I have a bit of experience with flash and actionscript, but due to the fact that I don't use it frequently, it happens that I forgot most of what I can do.
    I am about to start a sound project but I wanted to make sure it works before starting research.
    I want to use actionscript to click on letters that will display on the screen, and each letter will trigger an audio loop independantly, hence creating music.I also want to be able to reset the animation, erase all letters and sounds in order to restart. Actually that is the main question
    If it is possible, how ? Would you mind giving me some tips for a "kickstart"

    Is it possible, with flash to put different sounds triggered by a set of a buttons into a track and play this track in a loop ?
    I want to make it so when you press for example buttons A, then B, then C, it will play the sounds A, B and C respectively in an infinite loop. So when you click A, B, C, D, E, it will play ABCDE.
    EDIT: I succeeded ! I had to use arrays to do that. But now I would like that instead of putting the sounds automatically into the array at the beginning (red part), I want to be able to put by clicking on different buttons. It means if I click "A" first it will put the A into index 0, then B and put into index 1, then C and put into index 2, and so on. Also loop it indefinitely. How can ?
    var musicTrack = new Array();
    var aNote:a = new a();
    var bNote:b = new b();
    musicTrack.push(aNote);
    musicTrack.push(bNote);
    musicTrack.push(aNote);
    var musicChannel:SoundChannel;
    var currentSongIndex:int;
    function  onPlayBtnPressed() {
      currentSongIndex = 0;
      playSongFromIndex(currentSongIndex);
    function playSongFromIndex(songIndex:int) {
      musicChannel = musicTrack[songIndex].play();
      musicChannel.addEventListener(Event.SOUND_COMPLETE, songFinished);
      currentSongIndex++;
    function songFinished(e:Event) {
      if (currentSongIndex < musicTrack.length) {
           playSongFromIndex(currentSongIndex);
      } else  {
           currentSongIndex=0;
    onPlayBtnPressed();

  • 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.

  • How can I turn off auto play of an swf/flv using actionscript?

    Does anyone know how to turn off autoplay, using actionscript, of swf/flv?
    I'm trying to showcase four videos on the same page of a website. each video is a generic media player created in flash. when i test the movie, all the videos start playing at once.
    Also, if possible is there a way to have all four videos in the same media player?

    the media player has an autoPlay property.
    and yes, it also has a contentPath property.

  • Satellite L40-14F: No pic but sound playing DVD using WMP

    It is impossible to playback any DVD (no video), but there is sound.
    WinXP SP2 - WinMediaPlayer

    If you want to play DVD using the Windows Media Player then you will need an special codex.
    I would recommend using an software like Power DVD or WinDVD to play DVD..

  • How to Play a sample sound using Java

    Hi,
    I have an mp3 music files in database. When a user chooses a particular button, all the songs are fetched from the database.
    I have two buttons namely, 'Buy' and 'Play Sample'. If I click the 'Play Sample' button, a sample of the song has to be played (not the full song). If the user likes the sample, he can buy the full song.
    My question is how to achieve the 'Play Sample' using Java Swings and Sound. I have googled, but not find any solutions. Please provide me an example or link.
    Thanks in advance.

    HI
    Actually i am trying to create a JFrame which plays an mp3 music file
    with the help of play and stop buttons in it ...
    i splitted the frame into two
    i want a music file list in the first frame (JComboBox)
    and want to have play and stop button in the second frame .
    i had tried out some code in which the frame part is fine ,,,
    but i am not knowing how to play the file with those buttons ...
    here is the code and plz help me to move further ...
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JSplitPane;
    public class AudioFile extends JFrame {
        public AudioFile() {
            setTitle("Music File");
            setSize(300, 400);
            JPanel jp1 = new JPanel();
            JPanel jp2 = new JPanel();
            JButton s= new JButton("STOP");
            JButton p= new JButton("PLAY");
            JLabel j1 = new JLabel("MusicFile");
            String[] musicfiles={"file:///home/swathi/Desktop/spot3.mp3","anitha.mp3"};
            JComboBox musiclist=new JComboBox(musicfiles);
            musiclist.setSelectedIndex(1);
            jp1.add(j1);
            jp1.add(musiclist);
            jp2.add(s);
            jp2.add(p);
            JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
                    true, jp1, jp2);
            splitPane.setOneTouchExpandable(true);
            getContentPane().add(splitPane);
        public static void main(String[] args) {
          AudioFile sp = new AudioFile();
            sp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            sp.setVisible(true);
    }

  • What's the best solution for audio out of sound files from a MacBook Air to both an amplifier and to a subwoofer amplifier? I'm using the MBA to play sound files for worship services at our church.

    I have a MacBook Air (13", 1.7GHz, 8GB RAM, 500GB SSD) that I'll be using to play sound files (primarily organ and piano) for worship services at my church. We'll be using a QSC RMX2450 650 Watts/Channel amplifier with Community CPL-27 speakers and also a JBL SUB 250P powered subwoofer with its own amplifier. What's the best option for getting sound out from the Mac to both of these amplifiers? 

    if you work with own recorded sounds you might wanna have a music program where you want to work with samples, steinberg has got very good ones (so they say)... but their really really ( ²) expensive(that's why almost no one haves them), magix haves good ones too bu their more for 'unprofessional' use, ableton haves really good ones too and they're not to difficult to use (if you know a bit of those programs you learn very quickly) and if you don't get them, there is a sort of manual built in it which explains and lets you do things to start (basics)
    i hope this helped, btw stereo speakers are always better if you buy good ones (no pc speakers), but if you don't think you need them, don't buy them...
    so again, i hope you have some ideas now

  • HT201335 apple tv mirroring using mac book pro 2012 with mavrick no TV sound only laptop speaker plays sound...

    I am using apple tv with macbook pro 2012 with os mavrick ...when I play video, my laptop speaker plays sound for that video instead of my TV where apple tv is connected ...why it is like that ?

    Just upgraded Mountain Lion ($20 from app store) then it works perfect!!!
    Thanks for your help!

  • Playing sound/beep on the handheld device using WebDynpro for Java (NW7.01)

    Does anybody know if we could play sounds or beeps on the handheld device using WebDynpro for Java (NW7.01)? We have a client requirement to have the handheld device beeps/makes different kind of sounds after the goods receipt is posted. We are looking for a way to play the sounds thatu2019s saved on the deviceu2019s directory. Appreciate any suggestions or input.
    Thank you!
    Teeracha

    Hi Terracha,
    you can use bellow mentioned methods for playing a sound using javascript :
    function playSound( url ){  
      document.getElementById("sound").innerHTML="<embed src='"+url+"' hidden=true autostart=true loop=false>";
    or
    https://github.com/admsev/jquery-play-sound
    $.playSound('http://example.org/sound.mp3');
    Hope that helps you as a workaround way.
    Regards,
    Srinivas Divakarla

  • So far I've been using Flash Player 11.2 which is the only normal playing sound newer versions are stereo sound streamed normal once the second is the center sp

    so far I've been using Flash Player 11.2 which is the only normal playing sound newer versions are stereo sound streamed normal once the second is the center speaker started to play

    Flash Player 11.2 is horribly insecure and no longer supported. Please update to Flash 11.6

  • Unable to load/play sound files using SoundEngine_LoadEffect

    Hi All,
    I am able to load/play sound files using SoundEngine_LoadBackgroundMusicTrack but unable to load/play sound files using SoundEngine_LoadEffect on iPhone Simulator. I am using the SoundEngine.h/cpp from Crash Landing. Oddly enough sound effects load and play succesffully when i start the app with 'Start with Performance Tool'. Does anyone know what is actually going on.
    Also i would like to know what is the difference between playing sound files using these two methods. What are the restrictions on individual sound file types for each method.
    Thanks

    I was able to load/run the sound effects after using Simulator - iPhoneOS 2.1 in the Active Target/Build drop down on Xcode toolbar. Both Active SDK, and Active Executable should be 2.1 in order to play the sound effects.

  • How to code a button to play and pause sound using load sound?

    how to code a button to play and pause sound using load sound?I have used load sound methos to attach the sound.Can anyone help me?

    Hey thnx,
    I have used this code on sound's button's frame.and my stop n play button is on another screen.main sound button and stop button is on diffrent screen.
    Here is my code-
    stop();
    adaDrut1.onRelease = function () {
              mySoundC = new Sound(this);
              mySoundC.loadSound("F#/Bhajni1.ark", true);
    mySoundC.onSoundComplete = function() {
    _root.mySoundC.start(0,999); }
             gotoAndPlay("play2");
            _global.myTaalLaya = "Low1";
    adaDrut1 is a sound button.And there are lot of buttons with diffrent sound.
    Thanks..

Maybe you are looking for