On/off sound in a button in flex4

hello everybody, i want to make a website by flex.in that have sound  effect. i want when i load page have sound and if i don't want to listen  i can click button.the sound will stop play and else. But i don't know  how to make on/off sound by a button click
i done:
in actionscript file                Sound_playExample1.as: i write code
package myComponents {
    import flash.display.Graphics;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.events.ProgressEvent;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.net.URLRequest;
    public class Sound_playExample1 extends Sprite {
                private var snd:Sound = new Sound();
        private var channel:SoundChannel = new SoundChannel();
        public function Sound_playExample1() {           
            var req:URLRequest = new URLRequest("myComponents/soundall.mp3");
            snd.load(req);              
                channel = snd.play(0,6);   
// ActionScript file
in my Main.mxml:i write
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:MyComp="myComponents.*"
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    <fx:Script>
        <![CDATA[
            protected function button1_clickHandler(event:MouseEvent):void
                // TODO Auto-generated method stub
        ]]>
    </fx:Script>
    <fx:Declarations>
         <MyComp:Sound_playExample1/>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Button x="177" y="71" label="Button" click="button1_clickHandler(event)"/>
</s:Application>
can u help me please what i have to do. if you know you can
Additional for this code.thanks

// below code sinppet should go into on button click event handle method.
if
(pausePosition==0 ){ if(channel!=null){pausePosition = channel.position;
channel.stop();
sound.setStyle("icon",soundOffClass);  // mute
}else{ 
if(channel!=null){channel.stop();
channel = snd.play(pausePosition);
sound.setStyle("icon",soundOnClass); // un mute , this should be default as
pausePosition=0;

Similar Messages

  • Sound on/off by click a button in flex4????

    hello everybody, i want to make a website by flex.in that have sound  effect. i want when i load page have sound and if i don't want to listen  i can click button.the sound will stop play and else. But i don't know  how to make on/off sound by a button click
    i done:
    in actionscript file                Sound_playExample1.as: i write code
    package myComponents {
        import flash.display.Graphics;
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.events.ProgressEvent;
        import flash.media.Sound;
        import flash.media.SoundChannel;
        import flash.net.URLRequest;
        public class Sound_playExample1 extends Sprite {
                    private var snd:Sound = new Sound();
            private var channel:SoundChannel = new SoundChannel();
            public function Sound_playExample1() {           
                var req:URLRequest = new URLRequest("myComponents/soundall.mp3");
                snd.load(req);              
                    channel = snd.play(0,6);   
    // ActionScript file
    in my Main.mxml:i write
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:MyComp="myComponents.*"
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
        <fx:Script>
            <![CDATA[
                protected function button1_clickHandler(event:MouseEvent):void
                    // TODO Auto-generated method stub
            ]]>
        </fx:Script>
        <fx:Declarations>
             <MyComp:Sound_playExample1/>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <s:Button x="177" y="71" label="Button" click="button1_clickHandler(event)"/>
    </s:Application>
    can u help me please what i have to do. if you know you can
    Additional for this code.thanks

    // below code sinppet should go into on button click event handle method.
    if
    (pausePosition==0 ){ if(channel!=null){pausePosition = channel.position;
    channel.stop();
    sound.setStyle("icon",soundOffClass);  // mute
    }else{ 
    if(channel!=null){channel.stop();
    channel = snd.play(pausePosition);
    sound.setStyle("icon",soundOnClass); // un mute , this should be default as
    pausePosition=0;

  • On/off sound by a button in flex

    hello everybody, i want to make a website by flex.in that have sound effect. i want when i load page have sound and if i don't want to listen i can click button.the sound will stop play and else. But i don't know how to make on/off sound by a button click
    i done:
    in actionscript file                Sound_playExample1.as: i write code
    package myComponents {
        import flash.display.Graphics;
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.events.ProgressEvent;
        import flash.media.Sound;
        import flash.media.SoundChannel;
        import flash.net.URLRequest;
        public class Sound_playExample1 extends Sprite {
                    private var snd:Sound = new Sound();
            private var channel:SoundChannel = new SoundChannel();
            public function Sound_playExample1() {           
                var req:URLRequest = new URLRequest("myComponents/soundall.mp3");
                snd.load(req);              
                    channel = snd.play(0,6);   
    // ActionScript file
    in my Main.mxml:i write
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:MyComp="myComponents.*"
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
        <fx:Script>
            <![CDATA[
                protected function button1_clickHandler(event:MouseEvent):void
                    // TODO Auto-generated method stub
            ]]>
        </fx:Script>
        <fx:Declarations>
             <MyComp:Sound_playExample1/>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <s:Button x="177" y="71" label="Button" click="button1_clickHandler(event)"/>
    </s:Application>
    can u help me please what i have to do. if you know you can Additional for this code.thanks

    Hi,
    This is complete solution of your issue.Let me know if u find and issue.
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/halo"
                  creationComplete="application1_creationCompleteHandler(event)"
                  >
        <fx:Script>
            <![CDATA[
                import mx.events.FlexEvent;
                private function onClick():void
                    createSound();
                    channel = sound.play();
                private function offClick():void
                    if(channel != null)
                        channel.stop();
                private var sound:Sound;
                private var channel:SoundChannel = new SoundChannel();
                protected function application1_creationCompleteHandler(event:FlexEvent):void
                    isPlaying = false;
                    onOff();
                private function createSound() : void
                    var req:URLRequest = new URLRequest("assets/audio1.mp3");
                    if(channel != null)
                        channel.stop();
                    if(sound != null)
                        sound = null;
                    sound = new Sound();
                    sound.load(req);
                [Bindable]
                private var isPlaying : Boolean;
                protected function onOff():void
                    if(isPlaying == false)
                        onClick();
                        isPlaying = true;
                        return;
                    else
                        offClick();
                        isPlaying = false;
            ]]>
        </fx:Script>
        <s:HGroup>
            <s:Button label="{isPlaying == false? 'ON' : 'OFF'}" click="onOff()"/>
        </s:HGroup>
    </s:Application>
    with Regards,
    Shardul Singh Bartwal

  • Every time I unmute my iPad, the sound efx does not come back. I can hear my keypad and the on/off sounds but no app sounds.

    Every time I unmute my iPad, the sound efx does not come back. I can hear my keypad and the on/off sounds but I can't here the sounds from deleting photos, clicking on apps that are on my iPad. It does this every time I unmute my iPad. Please advise.

    Hello PearldiamondMD,
    I was thinking of a few recommendations for you. I recommend our iPhone Troubleshooting Assistant found here http://www.apple.com/support/iphone/assistant/phone/#section_1. Start at section 1, if that doesnt fix it, then section 3, and if all else does not work, section 5. At section 3 I recommend closing ALL the apps.
    Here is section 1 to get you started.
    Restart iPhone
    To restart iPhone, first turn iPhone off by pressing and holding the Sleep/Wake button until a red slider appears. Slide your finger across the slider and iPhone will turn off after a few moments.
    Next, turn iPhone on by pressing and holding the Sleep/Wake button until the Apple logo appears.
    Is iPhone not responding? To reset iPhone, press and hold the Sleep/Wake button and the Home button at the same time for at least 10 seconds, until the Apple logo appears.
    If your device does not turn on or displays a red battery icon, try recharging next.
    All the very best,
    Sterling

  • Sound and brightness buttons dont work anymore

    my sound and brightness buttons dont work any more unless I hold down the function button. This happened after I downloaded the new update I think. Is there any key combination that I could have hit that made this happen?

    Go to System Preferences->KeyBoard & Mouse->KeyBoard and make sure "Use the F1-F12 keys to control software featues" is off. It probably got turned on somehow by the update.

  • Will not:  rotate screen, camera will not work, iPad will not turn off, sound on side.

    Ipad will not turn off, sound button does not work, camera does not work,  screen will not rotate.  Have new ios and update.

    Reset all settings
    Settings>General>Reset>Reset All Settings
    Note: Data will not be affected but settings will be reset.

  • Sound On / Of Button

    Hello
    I found this tutorial where they teach you to add a sound on
    of button
    TUTORIAL
    But as you can see there is no ON or OFF button here.. I
    tried adding the symbols On and Off seperatly. But with the action
    script i got a bit mixed up and at one point of the movie both the
    labels are visibile at the same time..
    My
    movie
    sound_btn_on._alpha = 0;
    var mySound:Sound = new Sound();
    mySound.attachSound("myTrack");
    mySound.start();
    var soundStarted:Boolean = true;
    sound_btn_off.onRelease = function() {
    soundStarted = !soundStarted;
    if (soundStarted) {
    this._alpha = 100;
    mySound.start();
    } else {
    this._alpha = 0;
    mySound.stop();
    sound_btn_on._alpha = 100;
    sound_btn_on.onRelease = function() {
    soundStarted = !soundStarted;
    if (soundStarted) {
    this._alpha = 0;
    mySound.start();
    sound_btn_off._alpha = 100;
    } else {
    this._alpha = 0;
    mySound.stop();
    Any idea??
    Thank you.

    > sound_btn_on._alpha = 0;
    > var mySound:Sound = new Sound();
    > mySound.attachSound("myTrack");
    > mySound.start();
    > var soundStarted:Boolean = true;
    > sound_btn_off.onRelease = function() {
    > soundStarted = !soundStarted;
    > if (soundStarted) {
    > this._alpha = 100;
    ONOFF.gotoAndStop(2);
    > mySound.start();
    > } else {
    > this._alpha = 0;
    ONOFF.gotoAndStop(1);
    > mySound.stop();
    > sound_btn_on._alpha = 100;
    > }
    > };
    >
    make a movie clip ONOFF and on frame 1 place the OFF button
    look
    and stop action, on frame the the ON button look and the
    stop(); action.
    Then simply add what's above....
    Best Regards
    Urami
    "Never play Leap-Frog with a Unicorn."
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Hi I have a MacBook Pro 2011 i7 and it stays on for about 4 hours then the screen go's fuzzy and I have to turn it off by the power button has anyone had this problem thanks mike

    I Have a MacBook Pro i7 2011 it stays on for about 4 hours then the screen go's all fuzzy and I have to turn it off by the power button has any body else had this problem thanks mike

    My guess would also be a failling connection between your logicboard and your GPU. See 2011 MacBook Pro and Discrete Graphics Card
    For most users it starts with some random crashes and freezes like you describe it. And then it just gets worse and worse. There are still no "good" solutions, sadly. This is a hardware problem from the production.

  • So I have an iPad with the smart cover, and it's usually supposed to turn on the iPad when u open it, but it's no doing that for me. Nor is it turning off without pressing the button. What is the meaning of this?

    So I have an iPad with the smart cover, and it's usually supposed to turn on and off the iPad when u open it and close it, but it's not turning on for me. Nor is it turning off without pressing the button. What is the meaning of this?what caused it to be this way? Is there someway that I could fix it?

    Wait a sec did this just start?
    You set up the smart cover function in settings (you did that, right?) so, if you did that and it's failed you make an appointment at your nearest Genius Bar now.

  • Where in gods name is the homesharing button, I see a little cloud that you cannot click on and tells you what account you have but thats is. There's an option for turning on and off homesharing, but no button to access the actual library of the other PC

    Where in god’s name is the homesharing button, I see a little cloud that you cannot click on and tells you what account you have but that's it. There's an option for turning on and off homesharing, but no button to access the actual library of the other PC. On either PCs. Both are logged in and both are registered for homesharing. however because apple keeps updating and moving things around for no reason there appears to be no way of accessing the homsharing button in the latest version of itunes. the website refers to " Once set up, all the libraries from your computers you've enabled Home Sharing on will show up in the SHARED area of iTunes:" well I have searched all over in the recent itunes versions and there is no "shared area" to be found.
    Please find the attachment of a screen cap of my itunes.
    If anyone can help by telling me where it has been moved to or if it even still exists that would be much appreciated.

    Welcome to the Apple Community.

  • My iphone 4s' screen is black, but it's still on and charging. I broke my lock screen button so I am unable to turn it off using the home button and lock button. Is there any other way my phone can restart or turn off ? Is my phone broken for sure?

    My iphone 4s' screen is black, but it's still on and charging. I broke my lock screen button so I am unable to turn it off using the home button and lock button. Is there any other way my phone can restart or turn off ? Is my phone broken for sure?

    Kbkohn wrote:
    I am in tears right now because I entered all my 11month old sons milestones into my phone and now I have nothing I'm so upset and am hoping there is a way to get this information back. 
    Most intelligent people would not store such sensitive data on a device that could so easily be lost, stolen, or damaged.  Even if they chose to do so, they would use the device as designed and regularly sync and backup that device as described in the User's Guide.
    Have you done so?  If you have, all of the data is either in iCloud or iTunes on your computer.  Replace the device and restore the new iDevice with the backup of the old one.

  • Multiple sounds in one button

    would you kindly give me a suggestion that how to make multiple sounds in a button of a windows form application. actually, being a newb i'm trying to develop a piano application by C# for my own interest. the problem is, when i press one button it plays
    too long & i had to wait until the wav file is finished & after that i had to press another button. what's the code for playing multiple sounds together in one button? u know, then i can play chords too. would you kindly explain or give a code?

    Hi Rinku,
    This is an example for you:
    A Piano Key Control in C#
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • I want to know how to clear the text area by the push off my next question button and ask a new ques

    I want to know how to clear the text area by the push off my next question button and ask a new question - also I want to know how to code in my project to where a user can enter a math question in one border container and the answer enters into the next container
    heres my code so far
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" backgroundColor="#1E5C75">
        <fx:Script>
            <![CDATA[
                protected function button1_clickHandler(event:MouseEvent):void
                    //convert text area into labelid to be identified by actionscript
                    richTextLabel.text = myArea.text;
            ]]>
        </fx:Script>
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <!--container 1-->
        <s:BorderContainer borderWeight="7" x="28" y="10" width="200" height="138">
            <s:layout>
                <s:VerticalLayout paddingTop="10" paddingBottom="10"
                                  paddingLeft="10" paddingRight="10"/>
            </s:layout>
            <!--data Entry control-->
            <s:TextArea id="myArea" width="153" height="68"/>
            <!--end of data entry control-->
            <s:Button width="151" label="ask a question" click="button1_clickHandler(event)"/>
        </s:BorderContainer>
        <!--container2-->
        <s:BorderContainer borderWeight="7" x="509" y="10" width="200" height="138">
            <s:layout>
                <s:VerticalLayout paddingTop="10" paddingBottom="10"
                                  paddingLeft="10" paddingRight="10"/>
            </s:layout>
    <!--data entry control-->
            <!--convert tne data entry control into a label id in actionscript-->
            <s:Label id="richTextLabel" width="153" height="68"/>
            <s:Button width="151" label="next question" click="button1_clickHandler(event)"/>
        </s:BorderContainer>
        </s:Application>

    This is a user to user support forum.  We are all iphone users just like you.
    You are not addressing Apple here at all.
    This is an odd way to ask your fellow iphone users for help. Berating oterh users will not help you.
    "it's too fragile"
    No it is not.  i have never damaged one, nor has anyone I know.
    " U loose data when Ur phone is locked"
    No you don't.  Why do you think this?
    "and there is no customer support!!!  "
    Wrong yet again.  Apple has an 800 number and they have many retail stores and they have support articles that you can access using the search bar. Or you can contact them throgh express lane online
    "but I will go back with Blackberry "
    Please do.
    Good ridance

  • Grey screen with message "turn off computer with power button until switch off then press again power button"

    Dear all,
    I'm very hungry with my iMac and my Time Capsule :
    I try for two weeks to restore my iMac without any success...
    I wait 80 hours to finally have the message again and again : "to restart your computer : turn off computer with power button until switch off then press again power button".
    But my iMac do not work !
    Could you help me?

    Hello, that's a kernel panic...
    http://thexlab.com/faqs/kernelpanics.html
    Could be many things, we should start with this...
    "Try Disk Utility
    1. Insert the Mac OS X 10.6 Install disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu at top of the screen. (In Mac OS X 10.4 or later, you must select your language first.)
    *Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.*
    3. Click the First Aid tab.
    4. Select your Mac OS X volume.
    5. Click Repair Disk, (not Repair Permissions). Disk Utility checks and repairs the disk."
    http://docs.info.apple.com/article.html?artnum=106214
    Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    (Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.)
    If perchance you can't find your install Disc, at least try it from the Safe Boot part onward.

  • Will Switching Off the iPod Touch Button affect the process of erasing iPod Touch Contents?

    I have already deleted contacts, e-mail addresses, video,
    music, and photos on my iPod Touch (2nd Generation). I am presenting the list of items I deleted in "Notes" PRIOR to
    pressing "Erase Contents And Settings" button on that device.
    a.) Tel. Phone No. Neighbor
    b.) Christina Allison
    c.) Asian Stuff & Desserts
    d.) Youtube Channels/Links & Dailymotion
    e.) Apology & Appeal Letter
    f.) Movie Miscellaneous
    g.) Download Apple iOS4 – The new iPhone, iPod touch OS
    h.) Draft & Hello Dear Microsoft
    i.) SPSecFiles
    j.) Things to do on weekends
    k.) Brian prepares to write the letter certifying I am utilized to work.
    l.) Adjustment0S
    m.) Tweets and Twitter
    n.) VOCATIONAL EVALUATION
    At the time, my iPod Touch was fully charged. After deleting everything, I pressed "ERASE CONTENTS AND SETTINGS" button.
    I switched off my iPod Touch button IN ERROR because the process world take long. I repeat: After deleting everything, I pressed "ERASE CONTENTS AND SETTINGS" button. I switched off my iPod Touch button IN ERROR because the process world take long.
    What am I supposed to do next?

    - What happens when you turn the iPod back on?
    - For a 1G and 2G Pod, erasing all contents and settings can take hours and you need to have it connected to a chargings source.
    - You may have to place the iPod in recovery mode and then retore via iTunes.  For recoverymode:
    iPhone and iPod touch: Unable to update or restore

Maybe you are looking for

  • Custom Error Report for Truested Recon in OIM 11.1.1.5

    Hi, We are planning to have a custom scheduled task to generate csv report for failed recon events. We have some 4 trusted recons (2 custom + 2 GTC) in our environement. Does a DB query would be sufficient to meet our requirement. If yes please sugge

  • Can I easily match Pantone colors using Illustrator?

    Hi all, I run a small invitation supply company. Our primary design tool up until now has been Photoshop Elements. We recently purchased a $6000 printer from Xerox which is the 'gold standard' for graphic arts and Pantone approved. We also have a pan

  • A problem with args[i]

    Hi, I'm totally new to Java and I have a problem with my first program. It has to read the numbers from the input and checks wheter it is a prime number. This is what I have so far: public class PrimeNumbers public static boolean isPrime(int n) if (n

  • Photo merge panorama import file size?

    Is it necessary to convert files to jpeg when doing a photo merge panorama. I keep getting to told to convert to 8 bit from 16 bit and am not sure how to do that.

  • Exporting I-movie file to Quicktime

    Hi, when I try converting an i-movie file to quicktime on a external Hardrive or when trying to drag a quicktime file between external hardrives I get an error code -36 message. Can anyone share with me what this is about. I also get a message saying