Sitemap

Amicuk Programming Answers

On/off sound by a button in flex

2015-10-11   Views:0

Advertisement

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

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

The replay answer
Advertisement
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

Go to See the other 3 answers

On/off sound by a button in flex

Category:DefaultRelease time:2015-10-11Views:130

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[More]

On/off sound in a button in flex4

Category:DefaultRelease time:2015-10-11Views:130

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 butt[More]

Hot
In one of site collection at our SP2013 farm, we have "SharePoint Server Publishing" site feature and "SharePoint Server Publishing Infrastructure" site collection feature activated. One of user (UserA) create a page in a page library. [More]
I would like to know How I can convert an xls file to a txt file.Look for this on google.com: "Java Excel API" With that, it would be easy to convert an excel file to flat text.Read other 3 answers [More]
Since updating to Lion, Safari 5.1 has become very unstable. It crashes periodically for no observable reason. However, it always crashes when I try to print anything from Safare. Here is a copy of the printout from the last crash. Process:        Sa [More]
I can't seem to find a way to have more than one project window open at a time. This would be sweet. Currently chopping down a 60 minute rehearsal record into separate tracks. Kind of a pain. TIA TomTom Is that an iTunes question? Are you sure you po [More]
Hi seniors, While doing testing in QA i am not able to creat the infotype 0008 . I have schecked the table T510A,there i could find the Pay Roll Types & PayrollScale Area , Even system automatically picks up the data but when i am tring to select the [More]
i am doing the following where i have to create a new file in application server and transfer data to tht file from an internal table.but its saying file cant be opened.the path i am giving to parameter p_prefil is /tmp/prachi.txt. wats the prob..can [More]
Hello,  I have a HP Pavilion G6 - 2292sa The product no is C1Y93EA#ABU I have recently upgraded my system from windows 8 to the windows 8.1 update. Since I updated my audio won't work properly at all. During random intervals when playing songs on itu [More]
Ok I got 25 bucks in my iTunes account, but when I try to download somthing with my phone it tries to charge it to my debit card which has nothing on it. How can I resolve this problem???You had a purchase total of $25.95 but a credit of only $25.00, [More]
Hi Experts, I am trying to install SAP Netweaver AS trail version downloaded from sdn in my laptop. Laptop(Windows vista home premium OS) is in very good configurtation but unfortunately i have not succeeded with that. Can some one guide me like step [More]
Hi again! I 'm sure that many relative questions will have been asked again but is there any s a f e free video converter for ipod without all this adware types ? Is it also additionaly available for conversion of flv video types or do I need an extr [More]