One button for sound start & stop Flash AS3

Hi,
I am trying to create a sound button to start a sound and then stop it when clicked again.
I thought it would be easy because there is a code snippet for "click to play/stop sound"
I have my sound file in my library.
Below is the code that is not working:
Instructions:
1. Replace "http://www.helpexamples.com/flash/sound/song1.mp3" below with the desired URL address of your sound file. Keep the quotation marks ("").
CYOA2bttn.addEventListener(MouseEvent.CLICK, fl_ClickToPlayStopSound_11);
var fl_SC_11:SoundChannel;
//This variable keeps track of whether you want to play or stop the sound
var fl_ToPlay_11:Boolean = true;
Proxy-Connection: keep-alive Cache-Control: max-age=0 Cp>function fl_ClickToPlayStopSound_11(evt:MouseEvent):void
    if(fl_ToPlay_11)
        var s:Sound = new Sound(new URLRequest("CYOA2.wav"));
        fl_SC_11 = s.play();
    else
        fl_SC_11.stop();
    fl_ToPlay_11 = !fl_ToPlay_11;
CYOA2bttn is my button and CYOA2.wav is my sound file.
The error that comes up when I try to test the Flash file is:
Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.
    at CYOA_fla::MainTimeline/fl_ClickToPlayStopSound_11()
ANY SUGGESTIONS!?
Help PLEASE

hi
if the mp3 is in your library (in your fla) then the code is slightly different...
first, right-click on the sound in the library and select properties. Then tick "Export for ActionScript", and enter a name in "Class" (eg: mySound).
Then amend your code:
replace:
var s:Sound = new Sound(new URLRequest("CYOA2.wav"));
with:
var s:Sound = new mySound();
(replace "mySound" with whatever you entered for "Class" above.

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.

  • Something similar to 'gcstartup'  for automatic  start / stop

    Hi @ll
    Is there any similar to ‘/etc/rc.d/init.d/gcstartup’ script for an automatic start / stop for GoldenGate manager on a Server.
    I use an OBEY command in a start.txt file with start_ogg.sh file, but there are an OEM agent , a listener and the database on this machine and I would like to start all of them automatic at ones.
    Regards
    jfa

    Hi Nic:_W
    Thank for the answer.
    I have just modified the gcstartup like that :
    #!/bin/sh
    #Source Function Library
    SU=/bin/su
    DBST="N"
    if [ -f /etc/oratab ]
    then
    oratab="/etc/oratab"
    else
    if [ -f /var/opt/oracle/oratab ]
    then
    oratab="/var/opt/oracle/oratab"
    fi
    fi
    if [ -f "$oratab" ]
    then
    for i in `cat $oratab | grep -v '^#' | cut -d ":" -f2`;
    do
    if [ -f "$i/start_goldgate.sh" ] ;
    then
    user=`ls -l $i/start_goldgate.sh|awk '{print $3}'`;
    if [ $1 = start ];
    then
    DBST='Y'
    $SU - $user -c "$i/start_goldgate.sh ";
    else
    DBST='N'
    $SU - $user -c "$i/stop_goldgate.sh ";
    fi;
    fi;
    done
    fi
    and it works fine
    the content of start_goldgate.sh
    is
    cd /orasoft/app/ogg
    /orasoft/app/ogg/ggsci << EOF
    OBEY /orasoft/app/ogg/startup_ogg.txt
    EOF
    the content of startup_ogg.txt
    is :
    START MANAGER
    INFO ALL
    exit
    automatic restart of REPLICAT und EXTRACT parameters are in mgr.prm file.
    Analogue for stop*/shutdown* files with 'STOP MANAGER'
    regards
    jfa

  • Adding On/Off Button for Sound

    Hi,
    I have added a music sound to my website, how can I creat an
    Sound On/Off button for users to control?
    Thank you!

    Never mind, found it!
    http://www.partnersinrhyme.com/contact/tutorials.php?sub=Flash&cat=Adding%20Audio%20to%20P rojects&sno=62
    Sorry for the inconvenience.

  • How to use one button for mltiple task?

    hi, every body,
    how do i get one button to do mitple tasks,for example
    i have one button called(+), i'd like it to do addition and get the answer,in other word:
    1-press any number, called it 1.
    2-press the (+) button to add previous number.
    3-press anthor number, called it 5.
    4-again press the (+) button to add two numbers(1+5)and show the answer(6) .
    5-again press anthor number called it 4.
    6-press the (+) button again ,to add previous result(6) to current number(4)and show the answer that is(10) and so on...

    sorry for being late here is the code
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    import java.io.*;
    public class Calc2 {
    private JTextField d1;
    private JFrame frame;
    private int a,s,sum;
    public static void main (String[] args) {
    Calc2 g = new Calc2();
    g.go();
    } // close main
    public void go() {
    frame = new JFrame("Simple");
    Panel mainPanel = new Panel();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Font bigFont = new Font("sanserif",Font.BOLD,24);
    d1 = new JTextField(10);
    JButton b = new JButton("+");
    b.addActionListener(new AddListener());
    mainPanel.add(d1);
    mainPanel.add(b);
    frame.getContentPane().add(BorderLayout.CENTER,mainPanel);
    frame.setSize(500,600);
    frame.setVisible(true);
    }//close go()
    public class AddListener implements ActionListener {
    public void actionPerformed(ActionEvent ev) {
    String x = d1.getText();
    s = Integer.parseInt(x);
    d1.setText("");
    d1.requestFocus();
    String z = d1.getText();
    a = Integer.parseInt(z);
    sum = a + s;
    //Now how to keep track of a sum variable, and a currentValue variable.
    d1.setText(Integer.toString(sum));
    }//close inner
    }//close class

  • In table view, how to add one button for selecting page?

    Hi Experts,
    In the OBIEE 11.1.1.6, we have one uncommon requirement that customers want to randomly select actual page to view expected data in table view.
    For example:
    We make use of some columns to create one report in table view, and set 'Rows per Page' equal to '5',
    if this report contains 60 rows, it will have 12 pages, so customers want to select sepcial page number to view the some data. Is it possible to implement this requirement? Maybe we should write JS code.
    Note: Below table view, it has four buttons: First Row, Previous Row, Next Row and Display (500) rows in per page. So we want to add one button to select per page.
    We look at orgnial codes in WebBrowse, but do not know the following codes derive from which JS file.
    Could you please tell me how to find this file?
    <td class="TapeDeckCell"><img class="TapeDeckImage" onclick="" onkeypress="" src="res/s_blafp/viewui/pivot/first_dis.png" title="" alt="" ><img class="TapeDeckImage" onclick="" onkeypress="" src="res/s_blafp/viewui/pivot/previous_dis.png" title="" alt="" ><img class="TapeDeckImageEna" onclick="PTRowScroll('saw_5083_b','5','5', event)" onkeypress="PTRowScroll('saw_5083_b','5','5', event)" src="res/s_blafp/viewui/pivot/next_ena.png" tabIndex="0" onmouseover="PTTD(event, 'res/s_blafp/viewui/pivot/next_ovr.png');" onmouseout="PTTDO(event)" onmousedown="PTTD(event, 'res/s_blafp/viewui/pivot/next_dwn.png');" title="Next 5 Rows" alt="Next 5 Rows" ><img class="TapeDeckImageEna" onclick="*PTRowScroll*('saw_5083_b','-1)', event)" onkeypress="PTRowScroll('saw_5083_b','-1)', event)" src="res/s_blafp/viewui/pivot/showallrows_ena.png" tabIndex="0" onmouseover="PTTD(event, 'res/s_blafp/viewui/pivot/showallrows_ovr.png');" onmouseout="PTTDO(event)" onmousedown="PTTD(event, 'res/s_blafp/viewui/pivot/showallrows_dwn.png');" title="Display maximum (500) rows per page" alt="Display maximum (500) rows per page" > <Span class="TapeDeckRecords">Rows 1 - 5</Span></td>

    Hi Kobe,
    Thanks for listening me.
    I agree 11g have some issues unlike 10g. I've tried the same by creating a measure rcount(1) and name it as Page in RPD. I just pulled column Page in pivot table section 'Pivot Table Prompts' it is working but this may not answer your requirements.
    I would suggest to use the column in Prompt and go by between operator to allow user to select the rows between.
    In the report make Page as prompted.
    If you are okay with this can look forward to tweak it further, like values in the prompt multiple of 5 or 10s some thing like that.
    let me know updates on the same.

  • One button for Firefox window on the Task Bar instead of many

    I want to see just one button in the Task bar of my computer for Firefox window and not multiple, each window for each open tab. How can I do that?

    There is a setting for whether to inform Windows about each individual tab or only the active tab in each separate window. Here's where you can check and adjust that:
    "3-bar" menu button (or Tools menu) > Options > Tabs panel
    It's the last item: "Show tab previews in the Windows taskbar". If that is checked, you get ALL tabs in ALL windows on the Taskbar, and if it's unchecked, you only get the active tab in each window.
    Is that what you're looking for?

  • JTabbedPane and one Button for all Tabs

    Hello everybody,
    im new here an would say HELLOOO to everyone
    So ive got an issue.
    I am creating in "class A"  tabs for a JTabbedPane. In "class B" i create the JTabbedPane and creat instances of class A and add them to the TabbedPane.
    in Class B i also create a button, for save actions. When i click the button, a method "save()" will be called and read from every tab the Strings out of textfields.
    My problem now is, that it dont work, i call the save method with the instance from the tab, but it dont getText() from the textfield.
    For example:
    //create an instance tab, parameter is the save file
    Tab myTab = new Tab(file);
         //other code
    (Tab)myTab.save(); //here i eclipse cast to Tab automatically
    the save-Method in class A (Tab):
    save() {
    sysout(texfield1.getText)
    BTW how can i highlight code in this forum?

    You can add syntax highlighting by going into the advanced editor, that will add a button for it. Unfortunately there are no quick code tags :/
    After you find the button post your ACTUAL code. not just some random snippet which looks like your code. What you posted doesn't even compile.

  • One solution for 'iTunes has stopped working' message

    This worked in my case for iTunes 10.5 on a Dell Inspiron 1525 running 32-bit Vista. Symptoms started after I had to re-install it. Suddenly, whenever I tried to dl anything from the store, the dl would hit 100%, then I'd get the error message and DEP would then shut down the program. Upon re-starting, the dl wouldn't be in my apps list. (However, the actual dl WAS in my iTunes folder -- it's just that iTunes couldn't 'see' it.)
    I followed all all -- and I mean ALL -- the Apple guides over the course of 2 days with no success, even after numerous re-installs. Also tried every obsure suggestion I came across in the forums here -- and there were a lot!
    What finally worked for me were the suggestions at this link:
    http://www.vistax64.com/tutorials/87249-unable-install-latest-version-program-vi sta.html
    Following the suggestions there, I discovered uninstalled 'debris' residing in the App Data\Local and App Data\Roaming folders, specifically two Apple folders with content. I manually deleted these. These locations aren't mentioned in the Apple guide to manually uninstalling your iTunes. (http://support.apple.com/kb/ht1923)
    I also discovered debris throughout the registry which I removed manually with regedit. (Make backups of your registry before you go rummaging around in there! The usual warnings apply...)
    I also found two Quicktime files residing in the main Windows directory. (Ver 10.5 no longer installs Quicktime and I had un-installed my previous versions) I don't think these made a difference but 'off with their heads' anyway.  (^-~)
    BTW, all of this occurs after I used Revo Uninstaller in moderate mode. So even it didn't catch all the leftover debris. (I'm not brave enough to try it on a more aggressive setting...)
    Thought I pass this on in hopes it saves someone some grief....

    iTunes has stopped working message after having it open for one minute.
    I open itunes and a message comes up after a minute "itunes has stopped working". I got the update automatically to my Windows 7 64 bit pc 10.5.0.142.  After reading tons of probelms online about version 10.5
    I have decided to do nothing for now.  Seems people are putting hours into trying to fix it.  I was going to uninstall and reinstall but seems that isn;t working for to many people.
    How do we get some help from apple? 
    Anyone have any answers???  APPLE HELP please!!!!!!!!!!!!!!!

  • Is there anyway to just use one button for push to talk?

    I use ventrilo all the time but have been wanting to switch to skype. I can't stand using constant open mic so i wanted to use push to talk. On skype its always alt/control/shift plus something else is there anyway to make it only 1 key?

    In Firefox 4 by default the Stop, Go and Reload buttons are combined and attached to the right hand edge of the location bar.
    When you are typing in the location bar it will show the Go button. When a site is loading it shows the Stop button. At other times it shows the Reload button.
    If you want separate buttons, right-click on a toolbar and choose Customize, you can then drag and drop the stop or reload buttons and place them elsewhere. If you place them in the order "Reload-Stop" on the right hand edge of the location bar they will be combined again. For more details on customizing the toolbar see https://support.mozilla.com/kb/How+to+customize+the+toolbar

  • Keyboard Shortcut for Record Start/Stop?

    Soundbooth had keyboard shortcuts for everything except what I need.  I just want to be able to record tracks without hearing the click of my mouse at the end.  It seems like a pretty obvious and basic function, but I don't see anything in the help file on it.  Is there some workaround?

    With the Record dialog open, you can use the Space bar to start and stop the recording process.

  • DV9999us Sound Hardware stopped working for no reason

    This is my first time ever posting to a thread, so if I do a poor job explaining myself, I apologize.
    I have an hp dv 9999US laptop which months ago I upgraded to Win7-64 Pro.
    I had no problems until a few weeks ago, where all of a sudden one day my sound card stopped responding. The soft touch keys above the keyboard became unresponsive and there was a red "x" next to the speaker icon in the taskbar. If I click on it, I get a "not responding/wait/close" dialogue box. And under Device manager I have no listing for a "Sound, video, and game controllers." Sometimes Device manager shows a device listed as "Co-Processor" with a yellow exclamation after it, but when I try to install a driver for it windows is unable to find one.
    Also, when I try and install the driver for my sound card ( when it's not detected in DM) i get a code 10 error that the hardware is not responsive, or something to that effect.
    However, sometimes everything works fine. The soft touch keys are responsive, my conexant sound card displays in Device manager, and the volume settings in the taskbar are functional.
    I have NO idea what is causing this, but I've tried just about every driver I can find that's compatible with my integrated sound card.
    I've done some forum reading, and one thing people suggest is to make sure that the Microsoft UAA bus driver, but I'm a little hesitant to start installing random drivers without knowing what they'll do.
    Any advice would be greatly appreciated, and any additional information you need will be almost instantly provided.
    Thank you in advance
    Mike

    Try a smple reset:
    Press the sleep/wake button & home button at the same time, keep pressing until you see the Apple logo, then release(ignore the slide to power off).

  • Auto Start/Stop Oracle Database Lintener DBConslone on Linux

    Dear all
    I have install oracle 10.2.0 on redhat 4.7 every time i have to start manualy.
    it try with following scrip / process but database not starting automatically.
    Please any one can provide steps for auto start and stop oracel services on RedHat 4.7
    Once the instance is created, edit the "/etc/oratab" file setting the restart flag for each instance to 'Y'.
    TSH1:/u01/app/oracle/product/10.2.0:Y
    Next, create a file called "/etc/init.d/dbora" as the root user, containing the following.
    #!/bin/bash
    #chkconfig: 345 95 10
    #description: init script to start/stop oracle database 10g, TNS listener, EMS and isqlplus
    case $1 in
         start)
         su - oracle -c 'lsnrctl start'
         su - oracle -c 'dbstart'
    su - ora10g -c 'isqlplusctl start'
         su - oracle -c 'emctl start dbconsole'
         stop)
    su - oracle -c 'emctl stop dbconsole'
         su - oracle -c 'isqlplusctl stop'
    su - oracle -c 'dbshut'
    su - oracle -c 'lsnrctl stop'
         restart)
    su - oracle -c 'emctl stop dbconsole'
         su - oracle -c 'isqlplusctl stop'
    su - oracle -c 'dbshut'
    su - oracle -c 'lsnrctl stop'
         su - oracle -c 'lsnrctl start'
         su - oracle -c 'dbstart'
    su - ora10g -c 'isqlplusctl start'
         su - oracle -c 'emctl start dbconsole'
    esac
    create service on linux
    Actions >> System Settings >> Server Settings >> Services Then
    Actions >> Add Service Then
    Service Name = dbora Then Press Ok
    chmod a+x /etc/init.d/dbora
    Check is it running this service properly
    service dbora stop
    service dbora start
    showing error
    :bad interperter : no such file or directory
    Please forward me process/steps for auto start/stop oracel services

    :bad interperter : no such file or directorymeans that it could not find the interpreter which should be used to interpret the script.
    most probably this is caused by the shebang (#!/bin/bash)
    the default location of bash on RHEL (OEL/CentOS) is /bin/bash, which means that the shebang looks correct.
    can you make the shebang:
    #!/bin/bash -xso shelltracing is put on and execute script again?
    this will make clear if it is the shebang in your script, or in another script.

  • Start Stop of an app

    Hello,
    I am trying to stop and start a J2EE app (war or ear) on Weblogic (say) using JMX.
    When I look at Weblogic's Jython based scripting tool (WLST) and Websphere's corresponding offering (wsadmin) I do see jython and JACL functions called startApplicaton and stopApplication that seem to do the trick. That is they can be used to start and stop the apps on various targets.
    I am assuming that these jython and JACL functions use JMX calls under the covers. But when I look at the JMX api, I do not see any api to start and stop a J2EE app. (I do see apis to start and stop a server, but I'm looking for the start/stop of one J2EE app). I am specifically looking at the operations that are documented on the ObjectNames.
    So, how does one start or stop an application using just JMX.
    Or if someone can supply the underlying code of the startApplication and stopApplication Jython functions, that will help too!
    Thanks in advance!
    Jay

    JaySean wrote:
    http://community.vzw.com/t5/DROID-X-by-Motorola/DROID-X-Guide-Restart-Issues-amp-More/td-p/522082
    I believe the OP was wanting to know about apps restarting after app os force closed in the task manager not about the device rebooting, this post doesnt really apply.

  • Way to Erase All Start/Stop Time Data?

    I used a DJ plugin called BPMer to load the BPMs into all my MP3s. It had an option "Optimize Start and Stop Times." This helps the program skip ambient intros of songs in order to beatmatch, mix and crossfade more efficiently. The only problem is that the information is retained under Get Info:Options:Start/Stop Times even if the plugin is turned off. It is stored in the ID3 info. I am wondering how to universally delete this information or reset it to default because I do not feel like going to every song individually to reset it (I'd have to do it about 6000 times). I tried selecting multiple songs, but the Start/Stop does not show up under Options when multiple tracks are selected.
    Also don't suggest to re-run the BPMer program with the box unchecked for optimize start/stop times. I tried it. I figured out how to make BPMer not edit the times in the future, but it won't erase or overwrite the old start/stop info on tracks I already used it on.
    Sort of a weird problem, but any ideas to save me from the nightmare of doing this individually 6000 times are greatly appreciated.

    Doug Adams has a script over at his great site that should help with what you're trying to do.
    http://dougscripts.com/itunes/scripts/ss.php?sp=resettracksstartstop
    Matt

Maybe you are looking for