Sitemap

Amicuk Programming Answers

On/off sound in a button in flex4

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 butt

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
// 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;

Go to See the other 2 answers

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]

Sound on/off by click 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]

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]

Hot
I am trying to launch Firefox 9.0.1 on Windows 7 but it isnt working. I try to launch it and the application window does not show. When I look at the task manager and then look at the Applications tab, Firefox isnt listed. If I go to the Processes ta [More]
My old Apple ID is on my iPhone, but this has been transferred to a new Apple ID.  The iCloud on my phone is requesting the password for the old Apple ID, but this no longer exists.  How do I update the iCloud Apple ID on my iPhone?  When I try to ge [More]
I see an increasingly number of people having trouble with office 2012 running on 2008 R2 RDS servers, but i still am yet to find any good solution from Microsoft themselves. We now have two customers with 2008 R2 RDS servers and Office 2013, where u [More]
Hi all, Can any one help about this task.. I have writeen a java file which generates multiaxis chart by using JFreeChart API.... Say for ex.. public class multiaxis extends JFrame /// till know no problem... Can any one tell its possible to display [More]
how do i add music to my ipone using the new itunes software?The process is the same as with the older versions of iTunes. The only thing that's changed is how you get to the device page for your iPhone; you tap the iPhone button in the upper-right o [More]
What is the cost of having the WiFi hardware fixed/replaced on Iphone4s?? I have tried EVERYTHING that I have read on internet to restore/reset the software. Now I will resort to hardware replacement. How much does this cost???If this support article [More]
I'm trying a full restore in Lion, but it won't. States that there isn't enough space on the Mac HD. How do I restore everything from a recent Time Machine Backup?Thanks but I think it has something to do with the 'restore'. in the newest iTunes 11, [More]
OK here is what I heard: at a recent music pro's meet up I heard that 2 different people report some version of the info below. Then I called a mac tech pro, and he added 3 experiences more of the same in the last year. So this seems scary and that S [More]
I have a complex project, for commercial proposes. It's include menu in portuguese and english, audio Dolby 5.1 and 2.0 and subtitles in english, espanish and portuguese. The problem: When I simulate it on DVD studio Pro 4, everything works fine, It [More]
I am preparing a document and have pasted a table from Numbers. When I add text before the pasted table, the table itslef does not move down with the text. Does anybody know if there is a way to force a pasted table to reflow with the text? Thanks!Se [More]