sound looping problem

I have this code

When I run; He plays only once

its background music and I need to play loop ina

what I need to add to my code?

Thank you

my code:

import flash.media.SoundChannel;

import flash.events.MouseEvent;

import flash.events.Event;

var isPlaying:Boolean = true;

var lastposition:Number = 0;

var mysound:mew = new mew();

var soundchannel:SoundChannel = new SoundChannel (); So now that we can play the sound, how do we stop it? You cannot stop the sound using the Sound class (e.g. mysound.stop (); will not work). Another class is used to that - the SoundChannel class - which has a stop method that allows you to stop playing the sound.

SoundChannel = mysound.play (0,0); / / play a sound in the channel

soundchannel.addEventListener (Event.SOUND_COMPLETE, onPlaybackComplete1);

function onPlaybackComplete1(event:Event):void

{

lastposition = 0;

SoundChannel.Stop ();

BTN.btn_pause. Visible = false;

trace ("finished");

isPlaying = false;

}

btn.addEventListener (MouseEvent.CLICK, playsound);

function playsound(event:MouseEvent):void

{

If (! isPlaying)

{

SoundChannel = mysound.play(lastposition,0);

BTN.btn_pause. Visible = true;

isPlaying = true;

soundchannel.addEventListener (Event.SOUND_COMPLETE, onPlaybackComplete1);

}

on the other

{

lastposition = soundchannel.position;

SoundChannel.Stop ();

BTN.btn_pause. Visible = false;

/ * trace (lastposition.toFixed (0), mysound.length.toFixed (0)); * /

isPlaying = false;

}

soundchannel.addEventListener (Event.SOUND_COMPLETE, onPlaybackComplete);

function onPlaybackComplete(event:Event):void

{

lastposition = 0;

SoundChannel.Stop ();

BTN.btn_pause. Visible = false;

trace ("finished");

isPlaying = false;

soundchannel.addEventListener (Event.SOUND_COMPLETE, onPlaybackComplete);

}

}

No, sorry for the confusion, I stick the API reference.

You just need to change this line in your code:

SoundChannel = mysound.play (0, 0); / / play a sound in the channel

to do this:

SoundChannel = mysound.play (0, int.) His game ;// MAX_VALUE) in the channel

or any where where you call play() just pass int. For the second arg MAX_VALUE

Tags: Adobe Animate

Similar Questions

  • Sound loop

    Hi all

    I discovered a problem when I was creating a sound loop in Flash. I am using a similar code (here is a short version):

    var sound: Sound = null; It is initialized then not shown here

    var pausePos:Number = 0;     the time at which the noise has been stopped and must be restarted again

    Run sound paused

    function playSound()

    {

    If (Bo! = null)

    {

    Soundtrack.Start (pausePos, 99999); looping sound

    }

    }

    pause the sound and store time

    function pauseSound()

    {

    If (Bo! = null)

    {

    pausePos = soundtrack.position;

    Soundtrack.Stop ();

    }

    }

    On the stage is a button play/pause the sound. The problem is that when the sound is paused and then not again suspended, a loop is executed since the time stored "pausePos". Not only it starts for the first time in the era of "pausePos", but the loop is to the 'pausePos' at the end of his time.

    How can I solve this problem? The ins Manager onSoundComplete't the solution, because then there is a short delay. Any ideas?

    Thank you

    Michal

    you will need to use the full sound event to complete your sound, then.  You can remove the trailing white space in an editor of sounds and derivation of white space using the offset parameter.

  • Sound loop with a button

    So I used the tutorial on this page to make a button that turns the sound on and off (it's the only one I could find that actually works):

    [URL ="' http://www.entheosweb.com/Flash/flash_sound_button.asp ' ]

    But the only problem is that the sound does not loop. I found scripts that make loop sounds, but I don't know where to put in this code.

    PLEASE HELP ME! It was supposed to be done last week, and I do not tell the client that I don't know how to make his sound loop!

    Please tell me how to insert it into this code, because I don't want to make a button of his brand new. Thank you!

    The film that you have accessed to stop only the sound that is played. More than the sound is set to loop only 7 times, so it stops after a little more than a minute in all cases.

    Take a look at this variation that I built using the existing content. It is much simpler and does what you want: http://www.ddg-designs.com/downloads/soundControl.zip

  • TouchSmart HP Envy 15-j078ca - sound card problems

    Hello!

    I have a HP Envy 15-j078ca running windows 8.1 touchsmart and, recently, I noticed that my audio is static/crackling noises. A test, I plugged my head phones to see if it was a speaker problem or a problem of sound card and audio in my headphones was also static noises.

    Some of my audio programs tell me that it is a sound card problem.

    What I did: I followed the advice on another thread that had me uninstall the drivers and hand it to reset my bios settings can have my drivers to reinstall but I found that my audio worked perfectly! ... for about 2 hours then my cell phone was dead silent so I got this back a few days and the audio was fine again... for a few hours before he began to do staic noises again.

    I'm not really sure what the question is here, or how I can correctly solve this so any help would be appreciated!

    Thank you.

    Thank you for visiting the Forums HP's Support and Welcome.Thank you for the very detailed information very useful. I looked in your question about your computer laptop TouchSmart from HP ENVY 15-j078ca and popping sound or cracking.

    Here is a documenton the sounds troubleshooting.

    Please ensure that your edits were made on the laptop. In under his right click Device Manager and update driver. This is another step to try.

    1. right click the speaker icon in the lower right corner of your time.
    2. click on playback devices.
    3. click on speakers/headphones.
    4. click on properties.
    5. click on the Advanced tab in the Properties window.
    6. change the default menu Format in the highest quality.
    7. apply properties.
    8. click OK to close the Properties window.
    9. click OK to close the playback devices.

    Hope this helps you.

    Thank you.

  • Equium M50-244: loop problem internal ati2dvag.dll

    I had a M50-244 XP Home Edition (sp2) who have ATI onboard until I uninstalled it completely. The laptop has become totally useless vomit ati2dvag.dll inner loop problem and nothing seemed to heal so I decided to completely get rid of ATI.

    It started with VGASAVE which, with a few adjustments, work is fine and so my machine now. I disabled the video as controller he kept coming up with "new hardware found" and I didn't load the drivers more who would do what he started crashing again.

    Currently its on 'test' and I'm doing everything possible to see if it will crash once again, I hope not.

    Maybe I need another driver and activate the video controller, but I am hated for doing anything more now that his works normally, finally!

    Some said the installation of the graphics driver on the site omegadrivers.net and improves the performance of the graphics card.
    Maybe an installation of the driver from the site could be useful.

    Check it out

  • How one does sound loops on a track to create a song?

    I am new to apple.  I would like to know how to draw loops of sound on a track?  I chose the path and the instrument, now how to record sound? in my sony software you just draw on the road to a loop selected to place it on the right track and then read it.

    Wow, Sony must use a different concept based on your questions.

    I've never heard of a 'sound loop', don't know what that means.

    You or the other Records audio signals to an Audio track or MIDI signals from your MIDI keyboard on an Instrument track that creates regions. These area can be sealed off by dragging the upper right of the region.

    Then there are loops Apple Loops that you can access from the loop on the right browser. It is MIDI and Audio regions following the tempo (and pitch) of you project.

    It is always harder to relearn software (from another brand) that learning new software. I would like advice with a peak in the manual once a while to understand how different from what you are accustomed to Sony GarageBand.

  • Black screen of death and the sound loops

    Hello

    When I play a normal game on my cmoputer, I get a black screen and the sound loops always after 3 or 4 seconds. The computer crashes so I have to press the restart.

    After restarting the computer 10 times I fianley get an error on startup screen.
    I get this as information

    Probleemhandtekening:

    Clean van Gebeurtenisnaam: BlueScreen

    Versie van besturingssysteem: 6.1.7600.2.2.0.256.1

    Landinstelling-id: 1043

    Aanvullende information on clean says:

    BCCode: 333

    BCP1: 00000001

    BCP2: 00000002

    BCP3: 00000003

    BCP4: 00000004

    OS version: 6_1_7600

    Service Pack: 2_0

    Product: 256_1

    Bestanden die helpen bij het beschrijven van het clean:

    C:\Windows\Minidump\012710-20560-01.dmp

    C:\Users\Dennis\AppData\Local\Temp\WER-29640-0.SysData.XML

    Maybe you can help me please?  I think that the computer is hot? but I have an extra fan on the computer and the temparture is now 35 decrease.

    What can I do

    Greetz dennis

    does not not comodo firewall are you? It was originally my black screens, I disabled the firewall and defense ++ and everything worked fine since, and then they released a set day and difficulty for her.

  • is their an order for a loop. something like sym.loop("") or this. Sound.Loop(""). I especially need this

    is their an order for a loop. something like sym.loop("") or this. Sound.Loop(""). I especially need for two work to complete an audio file.

    Thank you.

    Hey, sabermaster -.

    Not at the moment, but you can create your own effects loop using triggers on the timeline.  What specific features do you want?

    -Elaine

  • A sound loop

    Hi all..

    Can anyone help me please with a sound loop? I have this code, that is suppoused to make loop, but it does not work thank you very much advance!

    var req:URLRequest = new URLRequest ("squeeak.mp3");
    var sound: Sound = new Sound();
    var controller: SoundChannel;

    var b:Boolean;

    {if(!b)}
    b = true;

    function soundLoaded(event:Event):void
    {
    controller = sound.play().

    play_btn.addEventListener (MouseEvent.CLICK, playSound);
    stop_btn.addEventListener (MouseEvent.CLICK, stopSound);
    }

    function playSound(event:MouseEvent):void
    {
    controller = sound.play (0, int.) MAX_VALUE);
    }

    function stopSound(event:MouseEvent):void
    {
    Controller.Stop ();
    }

    sound.addEventListener (Event.COMPLETE, soundLoaded);
    Sound.load() (req);

    }

    This loop for me.

    var req:URLRequest = new URLRequest ("1.mp3");
    var sound: Sound = new Sound();
    controller: SoundChannel var = new SoundChannel();    //<-- did="">

    var b:Boolean;

    if(!b)
    {
    b = true;

    function soundLoaded(event:Event):void
    {
    controller = sound.play (0,1000);   //<-- and="">

    play_btn.addEventListener (MouseEvent.CLICK, playSound);
    stop_btn.addEventListener (MouseEvent.CLICK, stopSound);
    }

    function playSound(event:MouseEvent):void
    {
    controller = sound.play().
    }

    function stopSound(event:MouseEvent):void
    {
    Controller.Stop ();
    }
    sound.addEventListener (Event.COMPLETE, soundLoaded);
    Sound.load() (req);

    }

    Try it.

    Best regards

    Peter

  • Sound loop do not repeat

    So, I downloaded a simple sound loop of the Flash Kit.

    I'm building a Flash site and want to sound in a loop once loads of film.  I added a stop and the movie button, in the case where the spectator is not the sound on.  I understand sound can be annoying.

    I add the following code to the IMAGE 1 of the movie.  Everything works fine, but once the loop is completed, it just stops.  How to continue a loop?  Also, as I navigate to other sections of the film... I want to keep playing and does not restart when I return to say "home".  Home starts as well the frame 1.

    Here is the code that I found:

    / code below sound control - external mp3 file.

    var music: Sound = new Sound (new URLRequest ("thebeat.mp3"));

    var sc:SoundChannel = music.play ();

    var isPlaying:Boolean = true;

    stop_btn.addEventListener (MouseEvent.CLICK, stopMusic);

    function stopMusic(e:Event):void

    {

    sc.stop ();

    isPlaying = false;

    }

    play_btn.addEventListener (MouseEvent.CLICK, playMusic);

    function playMusic(e:Event):void

    {

    if (! isPlaying)

    {

    sc = music.play ();

    isPlaying = true;

    }

    }

    isPlaying is declared a Boolean value in the beginning before isPlaying is tested in the if statement and before it has a value (true or false).  When you test a boolean unassigned, it is resolved to false: trace (isPlaying)

    if(!isPlaying);  tests! isPlaying = negation of isPlaying resolves to true when isPlaying is false

    You then set isPlaying = true so repeated tests of! isPlaying will resolve to false.

  • sound loop question

    Hi all!

    I'm pretty new to the use of the flash (I only need to use it for a project of United sound design) and I am having some problems.

    what I would do is create a button and loops of sounds in the State 'up' button. the only problem is that if I import sound to the "up" keyframe and choose the loop in the properties it maintains a loop until the end of time. what I'd like to that is - this loop if the mouse in box buttons. What should I do?

    (1) create a button

    2) double-click the (edit) button

    (3) create an extra layer for sounds

    (4) in this layer, create empty keyframes for all States (upward, over, down, HIT);

    (5) add the sound to the keyframe in ADDITION in the sound layer, set it to SYNC: start, loop

    (6) add the sound to the keyframe to the TOP in the layer of sounds, set it to SYNC: stop, loop

  • 9.3.2 sound notification problem

    Hello..

    I updated my iphone 5 to 9.3.2 days ago

    But I have a big problem... There is no sound notification at all

    ((Quand j'ai regarder deles de vidéos youtube le son va normalement))

    But when I open the GAMES or someone call or text - me me.  There is no sound at all

    When I use headphones... Everything happens normally

    The problem happens just with games and notifications

    I tried to reset all the settings and network settings but nothing has changed

    What I can do!

    Help, please

    Thank you

    Try resetting your device. It will help you. This will not erase your data stored on that device.

    • Press and hold the sleep/wake button
    • Press and hold the Home button
    • Press and hold both buttons until the display turns off and on again with the Apple logo on the subject.
  • Sound driver problems

    Hello world

    I reinstalled windows in my computer after you have removed all the files it contains.

    Therefore, I unfortunately lost the recovery partition.

    Now, after you have reinstalled the Windows 8 Pro, I installed all the drivers and everything works normally except the sound.

    However, I have been using Ubuntu after reinstaled Windows and I DIND'T have no problem with that.

    I thought that maybe this could be a problem inside, but when I use me headphones, or when I use my computer with my TV with HDMI, the problem persists.

    My computer is a HP ENVY m6-k010dx Sleekbook.

    So, what shoul I do to have it fixed?

    (Sorry for my bad English )

    ---------------- UPDATE ----------------

    I use a Linux Live USB to test the sound, as it could be any physical problem.

    However, it turned out that it really is a driver problem.

    I found a solution

    Just after installing Windows 8.1 the problem fixed itself

    Thanks for your help ():

  • Equium A100 - 147 Virtual Sound reinstall problem

    I read a few posts about the same problem I have, but with no definitive answer. I have the satellite A100-147 with Windows XP Media Center. I downloaded a few files updated on the Toshiba site (all for my model), including:

    acsil-xpmce-100008-en
    Assist-xpmce-10300-en
    confree-xpmce-59007ab-en
    csutil-xpmce-7211006
    Tonalite-xpmce-3221506-en
    display-xpmce-142004543
    fever disease-xpmce-2004
    Pcdt-xpmce-321u-en
    pwrsav-xpmce-70307i-en
    sdform-xpmce-2200-en
    SD-secure-xpmce-104-en
    Sound-xpmce-51005253
    Toupad-xpmce - 10001st - en

    and then: tvs-xpmce-10312-en (latest driver Virtual Sound for the A100-147)

    I uninstalled the old version of the virtual sound driver before attempting to install a new one. But as I've seen elsewhere, I get the message:

    "Toshiba Virtual Sound can't stand your computer."

    I spent all afternoon looking up and trying to find ways to solve this problem. I've since updated my BIOS (bios-550win). Not a thing I try it will work. I even deleted the references to his virtual in the registry where there was no ongoing conflict. It made no difference if.

    Could someone Toshiba please explain to me why I am told that I can not install which worked perfectly until this morning, before these updates, which are all intended for my laptop model? This is ridiculous. My apologies for my tone, but have lost hours on it, I'm extremely frustrated and you want just like it was back in my laptop (and before you ask, Yes, I tried a system restore, but that does not work either).

    Thank you

    Mac

    Hello
    I have the same problem. Please check the post: http://forums.computers.toshiba-europe.com/forums/thread.jspa?threadID=21761
    I have received no concrete response.
    :(

  • P series too hot and sound card problem

    Hello

    in recent weeks, I have a problem with the temperature. The P series of satellites is much too hot, even if only the essential progs are running, the processor runs with 100% very often. Without the Task Manager (to close the CPRS) of "windows" the machine crashes several times down!

    And since I've updated the driver sound in August this year, the sound may not be performed correctly. The sound card is not identified by diff. progs. MP3 direct cut and sound blaster, during the race.
    I can't save anything! So bad!

    Hello!

    Clean the laptop? You can use spry compressed air could blow the dust from the cooling fans. So do not disassemble anything.

    Which audio driver use? Toshiba or manufacturing as Realtek? Maybe there already is a new or try again with the old driver.

    Moreover, what Satellite phone do you have?

    Good bye

Maybe you are looking for

  • How to remove adds that cover the text making it impossible to read the text

    When an item is open, run to the bottom of the article an add is superimposed on the text makes it impossible to read the details of the new. Any attempt to remove fail it and the result of the opening to add it. How can I block the inclusion of thes

  • What is the difference between Tecra M11-h-13 and M11 - 10F?

    Hello Looking at the web page of Toshiba, I can't tell the difference between the Tecras M11-h-13 and M11 - 10F (besides the ~ 200 euros of cost difference).Can someone please enlight me? I see that there is a difference in the wireless card intel, b

  • HP envy 17-J006ED: failed to UPDATE the BIOS

    Hello I have a laptop of 17-J006ED DESIRE; Bought in December 2014. On the HP site, he had advice for the update of the BIOS. I downloaded the SP76843.exe file. I run the application directly from Windows; so I did not create a USB drive. I had the i

  • On a series of Satellite A overheating problem

    Well I posted this problem before thinking it was a problem with my settings of power and using drivers from ATI instead of toshiba, but the problem persisted and I managed to pin point the problem. Whenever I have my laptop running on battery its st

  • Recovery media for my laptop

    Hello. I have HP Pavilion f056nc 17. It is not very popular for laptop. I would like to know if my computer supports "Ordering the HP recovery media" (I'm the Slovakia.). I had Windows 8.1 when my computer 'born. ' 10 months ago, I installed Windows