Sound Loading in IE

Hi,
I'm trying to load a sound into various objects created on
stage dynamically.
Within Flash env. and FireFox, all goes right:
A container MC is created
A Sound object is created within that MC
onLoad function is registered for each container['s].sound
I can't figure out how to bypass the fact that IE wouldn't
fully-load the sound into memory. Needless to say this problem
stucks my movie from playing properly later on.
Following is how I create the sound obj.
Thanks.

Here are some thoughts
1. Is it possible a corrupted sound is caught in the cache on
the testing
machine?
2. Substitute other sounds to see if the sound is a problem.
3. Assign the onLoad BEFORE the loadSound method. It is
remotely possible
that at run time the loadSound gets an undefined reference to
onLoad.
Remember that thisMC_snd.onLoad = function is a runtime
assignment versus a
compile time and so for runtime do things in the order needed
for proper
memory assignment.
Lon Hosford
www.lonhosford.com
Flash, Actionscript and Flash Media Server examples:
http://flashexamples.hosfordusa.com
May many happy bits flow your way!
"Tal_CS" <[email protected]> wrote in
message
news:ed4a4k$ba$[email protected]..
> Hi,
>
> I'm trying to load a sound into various objects created
on stage
> dynamically.
> Within Flash env. and FireFox, all goes right:
>
> A container MC is created
> A Sound object is created within that MC
> onLoad function is registered for each
container['s].sound
>
>
> I can't figure out how to bypass the fact that IE
wouldn't fully-load the
> sound into memory. Needless to say this problem stucks
my movie from
> playing
> properly later on.
>
> Following is how I create the sound obj.
>
> Thanks.
>
>
> var thisMC:MovieClip =
this.createEmptyMovieClip("object"+i+"_mc", i);
> thisMC.snd = new Sound(thisMC);
> thisMC.snd.loadSound(objects_array
.src, false);
> // false = [I want the sound to load into memory as an
event sound, for
> later
> use. (short sounds)]
> [...]
> thisMC.snd.onLoad = function(success:Boolean):Void {
> if (success) { [...]
> // to this step IE doesn't reach!!
>

Similar Messages

  • Recover from a failed Sound.load()

    I've written a MP3 player for podcasts, and I am using the
    Sound.load() to load the MP3 file from a URL. From time to time,
    the download fails ... and an error occurs.
    I am able to catch the error just fine ... but now what? How
    do I restart the load? Or how do I recover from the failed
    download?
    Right now, I start the load, and also begin to play the sound
    to the user ... so they can begin to listen. In some cases I have
    seen the download of a 60 minute podcast fail at - maybe - 43:29.
    So they are listening, and might be 10-15 minutes in ... I catch
    the error ... and now what?
    I can't seem to find any documentation on what to do at this
    point ...

    You could use a custom event. In your error handling code
    dispatch your custom event, passing in something, like maybe the
    path to file to be loaded, then try to reload. Everytime it fails
    you will retry.

  • Sound loading

    Hey i have a GUI that plays sounds. but i am trying to preload all the sounds. does anyone know how i would do that. my problem is that when i click a button it plays a sound but it is chopped up. but when i click it the second time it works fine because the sound is in memory now. how do i pre load all sounds into memory. thanks
    mdawg

    I don't know if the problem can be solved like it can be with images, but I think there was a function in the images loading process that refers to waitForAll() after loading. It takes longer to load, but at you least you get everything..

  • Sound load problems

    Ciao!
    I have problems in running a projector under win 7.
    My projector load several SWF and each of them load different external MP3 that plays during the show.
    Under Win 7 sometimes the sound (Mp3) stops.
    Do you have any suggestion?
    I, sorry form my english...

    try:
    //Path MP3
    var pathMp3:String="../mp3/";
    // Playlist file Audio
    var arPlaylist:Array = new Array();
    // variabile booleana per caricamento iniziale audio
    arPlaylist.push("audio01.mp3");
    arPlaylist.push("audio02.mp3");
    arPlaylist.push("audio03.mp3");
    arPlaylist.push("audio04.mp3");
    arPlaylist.push("audio05.mp3");
    arPlaylist.push("audioa06.mp3");
    // Incremento - decremento volume
    var deltaVol=5;
    // Volume di default
    var levelVolume:Number = 80;
    // Inizializzo variabili per sapere audio in play e posizione
    var numAudioPlaying:Number=-1;
    var posAudioPlaying:Number=0;
    // Movieclip Libreria di suoni.
    // aSound è l'array che contiene tutti gli oggetti sound
    // istanziati nelle mc mcHolder_?? contenute dento a mcSoundLib
    // NON MODIFICARE
    var mcSoundLib:MovieClip = this.createEmptyMovieClip("mcSoundLib", this.getNextHighestDepth());
    var aSounds:Array = new Array();
    for (var i = 0; i<arPlaylist.length; i++) {
    var mcSnd:MovieClip = mcSoundLib.createEmptyMovieClip("mcHolder_"+i+1, i);
    var sndRef:Sound = new Sound(mcSnd);
    //trace(arPlaylist[i]);
    sndRef.loadSound(pathMp3+arPlaylist[i], false);
    aSounds.push(sndRef);
    // Funzione che verifica se sono staticaricati i file e manda in
    // esecuzione il primo della lista aSound[0]
    function intervalCheckSoundLoaded() {
    var refSlide = mcSlide;
    objIntervalCheckSoundLoaded = new Object();
    objIntervalCheckSoundLoaded.interval = function() {
    var tmpSoundLoaded:Boolean = true;
    for (var i = 0; i<1; i++) {
    //trace(aSounds[i].getBytesLoaded()+" - "+aSounds[i].getBytesTotal());
    if (aSounds[i].getBytesLoaded()<aSounds[i].getBytesTotal()) {
    tmpSoundLoaded = false;
    break;
    if (tmpSoundLoaded) {
    // Mando in play il file audio in prima osizione della lista
    soundLoaded=true
    playAudio(1);
    delete (objIntervalCheckSoundLoaded);
    } else {
    //trace("Audio non ancora caricati");
    setInterval(objIntervalCheckSoundLoaded, "interval", 20);
    // Funzione che assolve e dissolve gli audio
    function playAudio(num) {
    var numAudioToStop = numAudioPlaying;
    var numAudioToPlay = num-1;
    aSounds[numAudioToPlay].setVolume(0);
    aSounds[numAudioToPlay].start();
    numAudioPlaying=numAudioToPlay;
    objplayAudio = new Object();
    objplayAudio.interval = function() {
    var audioVol = aSounds[numAudioToPlay].getVolume();
    if (audioVol<levelVolume) {
    setVolumeAudio(numAudioToPlay, 5);
    } else {
    delete (objplayAudio);
    stopAudio(numAudioToStop);
    setInterval(objplayAudio, "interval", 400);
    // Mette in stop audio
    function stopAudio(numAudioStop){
    var numAudioToStop = numAudioStop;
    if (numAudioStop!=undefined){
    numAudioToStop=numAudioStop;
    }else{
    numAudioToStop = numAudioPlaying;
    objStopAudio= new Object();
    objStopAudio.interval = function() {
    var audioVolStop = aSounds[numAudioToStop].getVolume();
    if (audioVolStop>0) {
    setVolumeAudio(numAudioToStop,-deltaVol);
    } else {
    trace("stoppo audio num: "+numAudioToStop);
    aSounds[numAudioToStop].stop();
    posAudioPlaying=0;
    setVolumeAudio(numAudioToStop, levelVolume);
    delete (objStopAudio);
    if (numAudioToStop>-1) {
    setInterval(objStopAudio, "interval", 400);
    function stopAllAudio(){
    for (var i = 0; i<aSounds.length; i++) {
    aSounds[i].stop();
    numAudioPlaying=-1;
    posAudioPlaying=0;
    // Imposto volume oggetto Sound per assolvenza e dissolvenza
    function setVolumeAudio(numAudio, val) {
    aSounds[numAudio].setVolume(aSounds[numAudio].getVolume()+val);
    // Imposta volume per tutti gli oggetti sound
    function setVolume(val) {
    levelVolume = val;
    for (var i = 0; i<aSounds.length; i++) {
    aSounds[i].setVolume(val);
    // Mette in play audio in pausa
    function setPlayAudio(){
    aSounds[numAudioPlaying].start(posAudioPlaying);
    // Mette in pause audio in play
    function setPauseAudio(){
    posAudioPlaying=Math.round(aSounds[numAudioPlaying].position/1000);
    aSounds[numAudioPlaying].stop();
    var soundLoaded:Boolean=false;
    // richiamo funzione che verifica il caricamento audio.
    intervalCheckSoundLoaded();
    onEnterFrame = function() {
    LB = getBytesLoaded();
    TB = getBytesTotal();
    PC = (LB/TB)*100;
    //txtLoaded.text=PC+"%";
    //movie._xscale=PC;
    loaderbar.setbar(PC);
    trace(soundLoaded);
    if(TB>4 && PC == 100 && soundLoaded) {
    delete onEnterFrame;
    trace(soundLoaded);
    gotoAndPlay("start_frame")

  • Sound loads/plays too soon

    I created a loader for my swf file, and I'm using the
    streaming method for the mp3 track which seems to keep the audio
    and picture in sync, but the sound keeps loading and playing when
    the swf's about 50% loaded. The result is that the opening frames
    are dropped.
    Here's the problematic
    site.
    I've been searching the forum and I have not been able to
    find a solution to this.
    Can anyone help? I'm obviously no Flash expert, so any help
    would be MOST appreciated.
    Many thanks!

    Shan,
    Because I don't know how his clip is set up I gave him some
    possible functions he can use.
    If i was doing this i would be loading everything from
    external files and using the playback component and not the Sound()
    functions as these functions severely limit your ability to control
    the sound in the project, unless you find that the panning
    functions are something you really need.
    Please help by being constructive.
    DK,
    Heres what you will want to do. I believe you are using the
    loader component correct ? ok now since you are using this you can
    use the below action script with some adjustments to tell your
    audio to start by using the Sound functions or the playback
    component functions since I am not sure what you are using.
    If you are not using the loader component to load your
    pictures please let me know what you are using so I can get you on
    the right track, thanks.

  • Sound not loading

    I have the following code:
    myVars = new LoadVars();
    myVars.load("http://charlesnewmanpubl.com/Sweethearts_On_Parade_BRGK.txt");
    myVars.onData = function(src){
         myVars.decode(src)
         //trace(myVars.faFile);
         var faFile:String;
         var sound : Sound;
         if (myVars.faFile == undefined) {
            trace("not yet.");
        } else {
            faFile = myVars.faFile;
            trace(faFile + "!");//so far so good
            this.sound.loadSound("http://charlesnewmanpubl.com/media/"+faFile,true);
            clearInterval(param_interval);
         trace(faFile + "!!");//we're ok here
         this.sound.onLoad = function(success:Boolean) {//this is where it's failing
            trace(faFile + "!!!");//nada
            if (success) {
             this.playing = true
             this.sound.start (this.sound.soundIndex / 1000)
                trace("Sound loaded");//not here
         }else{
             trace("Sound failed");//or here
    This is a loadVars of a .txt, one variable of which is the name of a .mp3 file. I test to see if we've gotten all the data from the .txt, and then what the variable "faFile" is. That's then checked twice, both successfully. But when it gets to the section of whether the sound has actually loaded, and then should play, there's no reposrt.
    So I'm not loading the .mp3, but don't understand why.

    try: 
    myVars = new LoadVars();
    var sound : Sound;
    myVars.onData = function(src){
         myVars.decode(src)
         //trace(myVars.faFile);
         var faFile:String;
         if (myVars.faFile == undefined) {
            trace("not yet.");
        } else {
            faFile = myVars.faFile;
            trace(faFile + "!");//so far so good
            sound.loadSound("http://charlesnewmanpubl.com/media/"+faFile,true);
            //clearInterval(param_interval);
         trace(faFile + "!!");//we're ok here
    sound.onLoad = function(success:Boolean) {//this is where it's failing
            trace(faFile + "!!!");//nada
            if (success) {
             this.playing = true
             this.sound.start (this.sound.soundIndex / 1000)
                trace("Sound loaded");//not here
         }else{
             trace("Sound failed");//or here
    myVars.load("http://charlesnewmanpubl.com/Sweethearts_On_Parade_BRGK.txt");

  • Loading a sound twice causes error

    I am trying to load a sound in an mp3 player based on the selection of a user who
    has the .swf embedded in a web page. The first time the user makes a selection
    the selection loads with no problem. But if the user stops the sound or lets it play
    to the end and starts it again, I have to be careful not to call sound.load(URLRequest)
    again.
    If the user has chosen another selection to listen to, then load() has to be called again.
    The question is:
    how do I unload the sound Obj so another mp3 file can be loaded into it and played?
    I would think that load(another URLRequest) would overwrite the first and not complain.
    ( a deeper question is where is the sound file stored, by the browser -- in the case of
    html embed-- or does the Flash plugin maintain its own cache?)
    Thank you for time, attention, and advice, info, etc.
    JK
    PS: I realize that load() has more use than for sound objects

    Thank you for the reply.
    So, if there is a changeable play list length, I need to create new
    objects for each
    list item dynamically? And all the necessary objects cannot be hard
    coded. The
    name for each object has to be generated programmatically.
    As it is programmed, my app has server code that opens and reads a play
    list
    directory and creates an html list of the contents. So managing the
    content is
    just a matter of adding or removing files from the play list directory.
    This would mean that for every selection the user loads and plays, an
    object will
    persist. It would be nice to be able to unload selections to reduce the
    memory
    use. Or limit the size of each mp3 file, as well as the list length.
    As it is the only way to load a new selection is to reload the browser
    window.
    That suggests that the browser cache holds the content of the object,
    perhaps
    as a parent of the Flash plugin or activeX control(?).
    I am sorry this is long winded, but these nuances are obscure in
    manuals and
    texts.
    JK

  • Sound not loading - https IE

    Hi all,
    I have made a sound player. It works on all browsers when using http. But when using https it works on all browsers except IE.
    My script for loading is pretty basic, much like the one in the reference.
    I havn't been able to find a solution. Any ideas?
    Thanks,
    Jakob

    try: 
    myVars = new LoadVars();
    var sound : Sound;
    myVars.onData = function(src){
         myVars.decode(src)
         //trace(myVars.faFile);
         var faFile:String;
         if (myVars.faFile == undefined) {
            trace("not yet.");
        } else {
            faFile = myVars.faFile;
            trace(faFile + "!");//so far so good
            sound.loadSound("http://charlesnewmanpubl.com/media/"+faFile,true);
            //clearInterval(param_interval);
         trace(faFile + "!!");//we're ok here
    sound.onLoad = function(success:Boolean) {//this is where it's failing
            trace(faFile + "!!!");//nada
            if (success) {
             this.playing = true
             this.sound.start (this.sound.soundIndex / 1000)
                trace("Sound loaded");//not here
         }else{
             trace("Sound failed");//or here
    myVars.load("http://charlesnewmanpubl.com/Sweethearts_On_Parade_BRGK.txt");

  • Getting sound to load on any other computer

    I've never really been great at sound in flash, because it
    always struck me as being fairly complicated, but this is the first
    time it's legitimately not worked for me. I used the following
    code:
    var soundthrust:Sound = new Sound();
    soundthrust.loadSound("cannister_loop.mp3", false);
    var soundhit:Sound = new Sound();
    soundhit.loadSound("explode_4.mp3", false);
    to load two mp3s and later play them as sound effects when
    certain things occur (one's when the user presses a key, the other
    when a spaceship collides with the ground. Unfortunately, these
    sounds do not play on other computers, as I have loaded the
    executable file published through flash to the web here:
    http://valinet.com/~sheldon/climateorbiter.exe
    I even tried uploading the mp3s to the same folder online,
    assuming they might not be included in the executable, but alas,
    there is still no sound. How to I get sound to play on other
    machines? Is there a different way to create sounds (I can use
    wav's or anything else if those work better) or a different way to
    publish the flash document (although I dislike how viewing normal
    documents in browser lets the user see the area around the stage,
    unlike an exe) that will make the sound work? Thanks for the help,
    and sorry I'm a bit of a n00b.

    "kombucha284" <[email protected]> wrote in
    message news:[email protected]...
    > So why does sound work for me on my computer? Any idea?
    Also, I can't really tell as a result if that worked or not... I
    won't
    > know until tomorrow at school and by then it is due...
    Thanks!
    Ok, I looked at it again.
    To be able to control volumes of sound objects separately you
    need to attach each object to a separate movieclip, otherwise your
    volume control for the thrust sound will also affect the
    explosion sound. When you release the up arrow to let the lender go
    down
    the thrust volume goes to zero so the explosion sound can't
    be heard either. Secondly, if you don't use a preloader and someone
    pushes the arrow keys for the thruster before the thrust
    sound is completely loaded from the server you can get a missing
    sound.
    That doesn't happen on your local computer because the sound
    loads so quickly. The slower loading of the external sounds across
    the
    Internet makes a big difference.
    Either add a preloader or import the sounds into the library
    and use a linkage name and attach sound instead. Since you are
    short
    on time, that's what I would do.
    Also the two mp3 files are pretty small.. 47k and 25k so it
    won't add that much to the file size.
    1) import canister_loop.mp3 into the library
    2) right click on the sound in the library
    3) choose 'linkage' and give it a linkage name like
    'thrustSound'
    Make sure 'Export for Actionscript' and 'Export in Frame 1'
    are selected
    4) import explode_4.mp3 into the library
    5) give it a linkage name of 'explosionSound'
    6) create two empty movieclips to attach the sounds to..
    this.createEmptyMovieClip("one",10); // create clip 'one' at
    depth 10
    this.createEmptyMovieClip("two",11); // create clip two at
    depth 11
    7) attach the sounds to the movieclips...
    soundhit = new Sound(one); // soundhit belongs to movieclip
    'one' now
    soundhit.attachSound("explosionSound");
    soundthrust = new Sound(two); // soundthrust belongs to
    movieclip 'two' now
    soundthrust.attachSound("thrustSound");
    Now when you set the thrust volume to 0 for the thrust sound
    it won't make the explosion sound volume zero too.
    Hope that helps. I tested it and it works fine. How come you
    can't test it? Don't have Flash at home?
    I put the file on my website for you to test it.. click once
    to activate before using the arrow keys.
    http://www.kompanionkare.net/flash/lander10.html
    No place to land yet?
    tralfaz

  • Weird error of load streaming sound

    I developed Listening Internet Radio Program.
    It`s very simple.
    var sound:Sound=new Sound();
    var url:String='http://211.43.215.158:8388'
    Security.loadPolicyFile(url+'/crossdomain.xml');
    sound.addEventListener('progress',sound_progress)
    function sound_progress(e:Event):void{
      sound.play();
              sound.removeEventListener('progress',sound_progress)
    sound.load( new URLRequest(url) )
    And this works very very fine.
    But I got some weird error.
    This program works in Local.
    This program works in Internet Explorer 6.
    But This program doesn`t work in Google Chrome.
    same swf file, same website, same html.....
    But why not works in Google Chrome???????????????????????????????????????

    hi
    u can configure enveroment variables using oracle entriprice manager
    try to add env "PAHT" to server properties and set this to ur libs
    Do not forgrt to add nessary paths to this env .Okay ......
    this may work ...
    Asnka

  • 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

  • Dynamic Variable Naming for Sound Object

    Is it possible to dynamically name a variable? I'd like to
    create a new Sound Object on the fly, so that I can use the
    Sound.load() method multiple times. I would simply like to create
    and name the variable and add a number to the end of the name
    (i.e.; var "audio_1":Sound). I'm sure that this is possible.
    However, I can't seem to get it figured out.

    This code worked great! However, how can I set a global
    variable equal to the newly created Sound Object so that it is
    available globally via a reuseable reference?
    Here's an example of how I attempted to do this. Please note:
    audioObject is a global variable that I am trying to use to
    reference the new Sound Object in various places.
    audioObjectCount is a global variable that I am using to set
    or get the next number to use when dynamically creating the next
    new Sound Object

  • Sound issues in a replay and....

    Below is code for a simple game that has music that starts as soon as the game scene is reached....third scene. There are 4 buttons associated with the music, volume up, volume down, stop music,  and play music.
    As I said the music plays automatically at the start of the game, which I want. The up, down and stop volume work. The problems are.
    First, if you stop the music the play button will not start the music again.
    Second, none of the sound buttons work on a replay.
    Would it help to have a link to the game? I will up load and put a link in in a few minutes.
    I am stuck. I am new to actionScript. I am taking a class and the project is my final. I look forward to the day when Action
    I appreciate your help!
    Thanks,
    Michelle
    var bool:Boolean
    var score: Number = 0;
    var flag:Number = 1;
    var myTimer:Timer = new Timer(1000);
    var soundReq:URLRequest = new URLRequest("music.mp3");
    var sound:Sound = new Sound();
    var soundControl:SoundChannel = new SoundChannel();
    var volumeControl:SoundTransform = new SoundTransform();
    var flag2:Number = 1;
    count_txt.text = "0";
    myTimer.addEventListener("timer", timedFunction);
    insect_btn.visible = false;
    timer_txt.text = "20";
    function disappear(e:MouseEvent):void
        if (timer_txt.text == "0")
            launch_btn.removeEventListener(MouseEvent.CLICK, target);
            insect_btn.removeEventListener(MouseEvent.CLICK, disappear);
        else
            insect_btn.visible = false;          
            count_txt.text = String(++score);
    function target(e:MouseEvent):void
        if(flag==1)
            myTimer.start();
            flag = 0;
        insect_btn.x = Math.random()*625;
        insect_btn.y = Math.random()*475;
        insect_btn.visible = true;  
    function timedFunction(e:TimerEvent)
       var tc:int= 20 - myTimer.currentCount;
        timer_txt.text = tc.toString();
        if (myTimer.currentCount >19)
            insect_btn.removeEventListener(MouseEvent.CLICK, disappear);
            launch_btn.removeEventListener(MouseEvent.CLICK, target);
            myTimer.stop();
            gotoAndPlay("done_frame");
    function playAgain(evt:MouseEvent):void
        gotoAndPlay("play_frame");
    if(!bool){
    bool=true;
    sound.load(soundReq);
    soundControl = sound.play();
    function playSound(event:MouseEvent):void
               if ( flag2 == 0)
                soundControl = sound.play();
                flag2 = 1;
    function stopSound(event:MouseEvent):void
        soundControl.stop();
        flag = 0;
    function increaseVolume(event:MouseEvent):void
        volumeControl.volume += .5;
        soundControl.soundTransform = volumeControl;
    function decreaseVolume(event:MouseEvent):void
        volumeControl.volume -= .5;
         if (volumeControl.volume >= 0)
            soundControl.soundTransform = volumeControl;
        else
            volumeControl.volume = 0;
    insect_btn.addEventListener(MouseEvent.CLICK, disappear);
    launch_btn.addEventListener(MouseEvent.CLICK, target);
    btn_play.addEventListener(MouseEvent.CLICK, playSound);
    btn_stop.addEventListener(MouseEvent.CLICK, stopSound);
    btn_up.addEventListener(MouseEvent.CLICK, increaseVolume);
    btn_down.addEventListener(MouseEvent.CLICK, decreaseVolume);

    The sound control buttons are available for the entire timeline. Other than when I went to turn in a different project today I have been playing with this problem.
    Can you see anything wrong with the AS below? The only thing I can think of is it has to be a typo of some sort.  I gone over it so many times I don't think I even see it anymore.
    function handleClick3(e:MouseEvent):void
        if ( e.target == btn_again)
        gotoAndPlay("play_frame", "game_scn");
    btn_again.addEventListener(MouseEvent.CLICK, handleClick3);
    I just got this error code.  It happened when I click more than once on the sound button during the replay. I havn't had much success when I google these errors. I will do that next. But just in case you recognize it. Here it is:
    ArgumentError: Error #2068: Invalid sound.
        at flash.media::Sound/play()
        at find_the_butterfly_fla::MainTimeline/playSound()

  • Using Flashvars to load external mp3 files

    I am trying to find a very good step by step tutorial on using "Flashvars" to load external mp3 files, I have been searching on google and the many I have found fall short in some way or another. From what I have been able to gather, I have tried using the code in red (commented out), which works, and modify it to use "Flashvars". The code that works, the mp3 file is hard coded, but my goal is to use "Flashvars" which I am attempting to do in the code following the code in red. I am also including the html code. Any help will be greatly appreciated.
    Thanks,
    David
    var soundReq:URLRequest = new URLRequest("mardi_gras2.mp3");
    var sound:Sound = new Sound();
    sound.load(soundReq);
    sound.addEventListener(Event.COMPLETE, onComplete);
    function onComplete(event:Event):void
        sound.play();
    var soundReq:URLRequest = new URLRequest(root.loaderInfo.parameters.audio);
    var sound:Sound = new Sound();
    sound.load(soundReq);
    sound.addEventListener(Event.COMPLETE, onComplete);
    function onComplete(event:Event):void
        sound.play();
    HTML CODE
    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="550" height="400" id="mySoundvars" align="middle">
        <param name="allowScriptAccess" value="sameDomain" />
        <param name="allowFullScreen" value="false" />
        <param name="movie" value="mySoundvars.swf" />
       <param name="FlashVars" value="audio=mardi_gras2.mp3" />
        <param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />    <embed src="mySoundvars.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="mySoundvars" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" FlashVars="audio=mardi_gras2.mp3" />

    Ok waterlovinguy,
    I went back to my original code, and I got things to work... I think my whole issue was with the HTML CODE. So I decided to use the "SWFObject generator". I had never used it before, frankly I had never heard of it until I started my searches on "Flashvars".
    Thank you very much for all your assistance, PEACE,
    David
    Final Codes below
    var my_var:String = new String();
    my_var = root.loaderInfo.parameters.myflashvar;
    myText.text = my_var;
    var soundReq:URLRequest = new URLRequest(root.loaderInfo.parameters.audio);
    var sound:Sound = new Sound();
    var soundControl:SoundChannel = new SoundChannel;
    sound.load(soundReq);
    play_btn.addEventListener(MouseEvent.CLICK, playSound);
    stop_btn.addEventListener(MouseEvent.CLICK, stopSound);
    function playSound(event:MouseEvent):void
        SoundMixer.stopAll();
        soundControl = sound.play();
    function stopSound(event:MouseEvent):void
        soundControl.stop();
    HTML Code
                    <!>>
                    <!<![endif]>
                        http://www.adobe.com/go/getflashplayer
                        </a>
                    <!>>
                    </object>
                    <!<![endif]>
                </object

  • Flash with background sound (I got error #2037)

    Hallo.
    I am a beginner at AS3 programming. I like to make a flash with background sound (*.mp3 files from *.xml list). Everything works fine, but when I press "onClick" button I got output error.
    Error: Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful.
        at flash.media::Sound/_load()
        at flash.media::Sound/load()
        at proov_fla::MainTimeline/F_MP3_laadimine()
        at flash.events::EventDispatcher/dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at flash.net::URLLoader/onComplete()
    My Script:
    var MP3_PLAYLIST:String = "playlist1.xml";
    var LAADI_MUUSIKA:URLRequest;
    var MUUSIKA:Sound = new Sound();
    var MUUSIKA_KANAL:SoundChannel = new SoundChannel();
    var HETKE_MUUSIKA:Sound = MUUSIKA;
    var POSITSIOON:Number;
    var HETKE_INDEX:Number = 0;
    var KAS_MUUSIKA_MÄNGIB:Boolean = true;
    var XML_FAIL:XML;
    var MUUSIKA_NIMEKIRI:XMLList;
    var MP3_LAADIJA:URLLoader = new URLLoader();
    MP3_LAADIJA.addEventListener(Event.COMPLETE, F_MP3_laadimine);
    MP3_LAADIJA.load(new URLRequest(MP3_PLAYLIST));
    onClick.addEventListener(MouseEvent.CLICK, järgminelugu);
    function järgminelugu(e:MouseEvent):void
        MP3_PLAYLIST = "playlist2.xml";
        MP3_LAADIJA.load(new URLRequest(MP3_PLAYLIST));
    function F_MP3_laadimine(e:Event):void
        XML_FAIL = new XML(e.target.data);
        MUUSIKA_NIMEKIRI = XML_FAIL.track;
        LAADI_MUUSIKA = new URLRequest(MUUSIKA_NIMEKIRI[0].path);
        MUUSIKA.load(LAADI_MUUSIKA);
        MUUSIKA_KANAL = MUUSIKA.play();
    My full purpose will look like this http://uusrand.pri.ee/galerii/proov/

    Hallo.
    Can anybody help me to add an actionscript line(s) into attach file "newXML.fla".
    In this file I have a script to play mp3 files from xml list (this works).
    I also add button to load new mp3 fileslist from new xml file. But I don't know how.
    My Script:
    var MP3playlist:String = "http://uusrand.pri.ee/mp3/playlist.xml";
    var MP3file:URLRequest;
    var MP3SoundURL:Sound = new Sound();
    var MP3sound_channel:SoundChannel = new SoundChannel();
    var xml:XML;
    var playlist_index:XMLList;
    var xml_loader:URLLoader = new URLLoader();
    var MP3index:Number = 0;
    xml_loader.addEventListener(Event.COMPLETE, originalXMLfile);
    xml_loader.load(new URLRequest(MP3playlist));
    onClick.addEventListener(MouseEvent.CLICK, nextXMLfile);
    function nextXMLfile(e:MouseEvent):void
        if (MP3playlist == "http://uusrand.pri.ee/mp3/playlist_loodus.xml") {
            MP3playlist = "http://uusrand.pri.ee/mp3/playlist.xml";
        } else {
            MP3playlist = "http://uusrand.pri.ee/mp3/playlist_loodus.xml";
    function originalXMLfile(e:Event):void
        xml = new XML(xml_loader.data);
        playlist_index = xml.track;
        MP3file = new URLRequest(playlist_index[0].path);
        MP3SoundURL.load(MP3file);
        MP3sound_channel = MP3SoundURL.play();
        MP3sound_channel.addEventListener(Event.SOUND_COMPLETE, nextSong);
    function nextSong(e:Event):void
        if (MP3index < (playlist_index.length() - 1)){
            MP3index++;
        } else {
            MP3index = 0;
        var NextSongRequest:URLRequest = new URLRequest(playlist_index[MP3index].path);
        var NextSongURL:Sound = new Sound(NextSongRequest);
        MP3sound_channel.stop();
        MP3sound_channel = NextSongURL.play();
        MP3sound_channel.addEventListener(Event.SOUND_COMPLETE, nextSong);

Maybe you are looking for

  • How to Display a game score throughout the Scenes

    Hi there Actionscript geniuses. I have stumble upon this problem. As a novice in actionscript in particular and programming in general, I am very pleased that I manage to pull this scoreboard script ( listed below), for my quiz game. The script is si

  • CS6 Windows 8.1 Playback and Recording errors

    We are running Audition CS6 on newer Windows 8.1 computers, using the internal sounds cards to eliminate any USB or driver issues as culprits.  Here is a breakdown of our problems: When opening a file from an external program, Audition will not play

  • Now unable to use Touch Up Text Tool

    Since 2007, I've used a mac laptop for creating invoices in Quickbooks and saved them as pdfs. They are saved to my 2009 IMac as acrobat (9.4.1. version) pdfs. Over the years I have, on occasion, made minor edits using the edit text tool. Beginning y

  • Language barrier...

    I originally posted a similar message under the "compiling" forum, but after some thought I decided it fit better here since the issue wasn't necessarily specific to compilation (though it does affect it). I'm not trying to spam the forums, really, I

  • RMI JNDI Lookup in ServletContextListener

    Hi, I am attempting to do a JNDI lookup (using the RMIInitialContextFactory) of a session EJB inside a ServletContextListener. But when I do I get an exception saying it cannot find the name I lookup. If I set rmi.debug to true I can see that a 'Sock