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 6548675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:59:55+00:00 2026-05-25T11:59:55+00:00

The following AS3 code is sometimes causing the audio to play multiple times, almost

  • 0

The following AS3 code is sometimes causing the audio to play multiple times, almost simultaneously like a crazy echo. It usually works ok with that URL but when I use a https://soundcloud.com url it always freaks out. On rare occasions I think the issue has happened with local files even. I copied this code from somewhere else so I don’t entirely understand it. Do you see a problem with this implementation or is Flash just crazy?

var url:String = "http://md9.ca/portfolio/music/seaforth.mp3"; 

var request:URLRequest = new URLRequest(url);  
var s:Sound = new Sound();  
s.addEventListener(Event.COMPLETE, completeHandler);  
s.load(request);  var song:SoundChannel = s.play();  
song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);  


var time:Timer = new Timer(20);  
time.start();

function completeHandler(event:Event):void {    
  event.target.play();  
}  

function soundCompleteHandler(event:Event):void {   
  time.stop();  
}
  • 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-25T11:59:55+00:00Added an answer on May 25, 2026 at 11:59 am

    You are calling play() twice on the Sound object. Once when you create the variable song and again when the file is done loading.

    You might want to structure your code differently.

    var url:String = "http://md9.ca/portfolio/music/seaforth.mp3"; 
    
    var song:SoundChannel;
    var request:URLRequest = new URLRequest(url);  
    var s:Sound = new Sound();  
    s.addEventListener(Event.COMPLETE, onLoadComplete );  
    s.load(request);
    
    function onLoadComplete(event:Event):void 
    {    
      song = s.play();
      song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);   
      s.removeEventListener( Event.COMPLETE, onLoadComplete );
    }  
    
    function soundCompleteHandler(event:Event):void 
    {   
      trace( 'sound is complete' );  
      song.removeEventListener( Event.SOUND_COMPLETE, soundCompleteHandler );
    }
    

    I removed the Timer code as it did not do anything functional.

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

Sidebar

Related Questions

I am a AS3 novice learning PureMVC and want to write code following best
Make a new AS3 Document in Flash, paste in the following code and run
My AS3 application basically does the following (pseudo code from main application class) 3
Again pulling my hair out due to some Flex/AS3 weirdness. The following code does
I have a problem with the following Flash AS3-code: When I change Delete1 to
I have the following code (AS3 & CS 5.5): var regEx:RegExp = new RegExp(/(?:^|\s)(\#[^\s$]+)/g);
I have the following code in AS3: var str:String = '<TEXTFORMAT LEADING=2><P ALIGN=LEFT><FONT FACE=Arial
I have the following array as3 example: var arrayDefinitionsargsAmfPhp:Array = new Array(); arrayDefinitionsargsAmfPhp['tabela'] =
I have the following two projects in in Flex Builder 3: One AS3 library
Hey all, basically i have an empty AS3 fla file with just the following

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.