Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6985443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:40:51+00:00 2026-05-27T18:40:51+00:00

I have tried this for HOURS. There must be a simple solution to stop

  • 0

I have tried this for HOURS. There must be a simple solution to stop the sound and unload it in as3.

This is not all of my code, but in short I am loading random sounds. I need certian vars to be outside of the function so I can reference them with other functions for a progress bar.

How do I unload a sound so I can load a new one using the same names without getting an error the second time its called?

I have two buttons in this test. A play Sound and a Stop Sound Button.

here is my code:

var TheSound:Sound = new Sound();
var mySoundChannel:SoundChannel = new SoundChannel();

PlayButton.addEventListener(MouseEvent.CLICK, PlaySound);
StopButton.addEventListener(MouseEvent.CLICK, Stopsound);

function PlaySound(e:MouseEvent)
        {
        TheSound.load(new URLRequest("http://www.MyWebsite.com/Noel.mp3"));
        mySoundChannel = TheSound.play(0);
        }

function StopSound(e:MouseEvent)
        {
        delete TheSound;
        }

HERE IS THE ERROR I GET:

Error: Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful.
    at flash.media::Sound/_load()
    at flash.media::Sound/load()
    at Untitled_fla::MainTimeline/PlaySound()[Untitled_fla.MainTimeline::frame1:21]

UPDATE…. I TRIED STOPING THE SOUND AND THEN UNLOADING IT AS FOLLOWS

mySoundChannel.stop();
TheSound.close();

BUT NOW I GET THIS ERROR:

Error: Error #2029: This URLStream object does not have a stream opened.
    at flash.media::Sound/close()
    at Untitled_fla::MainTimeline/shut1()[Untitled_fla.MainTimeline::frame1:35]

I believe I am closer. Thanks so much for your help so far.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:40:52+00:00Added an answer on May 27, 2026 at 6:40 pm

    In order to stop the sound from playing, you first have to tell the SoundChannel instance to stop like so :

    mySoundChannel.stop();
    

    Once you did that, you can close the stream used by the sound instance by invoking the close method like so :

    TheSound.close();
    

    Also, the delete keyword is rarely used in as3 and you should not it while some methods are trying to access the variable you are deleting. If you want to dispose of the instance that is currently assigned to your TheSound variable, you should set its value to null. This way, flash will properly garbage collect the old Sound instance that is no longer used when it finds the appropriate time to do so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have tried this code to redirect a php page.but it s not working
I have tried to find a solution to this issue for many hours to
I have tried this but it does not work (even if I specify .wav
I have now tried to get this to work for a few hours but
I have tried this... Dim myMatches As String() = System.Text.RegularExpressions.Regex.Split(postRow.Item(Post), \b\#\b) But it is
i have tried this: <?php $fileip = fopen(test.txt,r); ?> this should have opened the
I have tried this but it doesn't work: tell application Preview set myfile to
I have tried this example http://www.bennadel.com/blog/1056-ColdFusion-CFPOP-My-First-Look.htm , but it retrieve emails from POP server.
I have tried this a few different ways and it always seems to fail.
I have tried this approach/hack: http://blog.blackwhale.at/2009/06/uibuttons-in-uinavigationbar/ The problem is this leaves a faint seam.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.