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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:23:51+00:00 2026-06-01T22:23:51+00:00

My as3 code to load external sound: var s:Sound = new Sound(); s.addEventListener(Event.COMPLETE, onSoundLoaded);

  • 0

My as3 code to load external sound:

var s:Sound = new Sound(); 
s.addEventListener(Event.COMPLETE, onSoundLoaded); 
var req:URLRequest = new URLRequest("getfile.php"); 
s.load(req); 

function onSoundLoaded(event:Event):void 
{ 
    var localSound:Sound = event.target as Sound; 
    localSound.play(); 
}

Then my php code to return the file:

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;

In onSoundLoaded event, how do i get the actual filename return from the php response?

  • 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-06-01T22:23:52+00:00Added an answer on June 1, 2026 at 10:23 pm

    They way to solve the problem is to use URLLoader http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html to load the data instead of using the Sound class. This is because you can listen to the HTTPStatusEvent.HTTP_RESPONSE_STATUS – http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html#event:httpResponseStatus event that wraps the response headers (which include the filename). The listener for event complete can be used unmodified as in your code because it returns the same data.

        var loader : URLLoader = new URLLoader();
        loader.addEventListener(Event.COMPLETE, onSoundLoaded); 
        loader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, onStatusResonse);
        var req:URLRequest = new URLRequest("getfile.php"); 
        s.load(req); 
    
        function onStatusResonse(event:HTTPStatusEvent):void 
        { 
           var headers:Array = event.responseHeaders;
           // iterate on headers to get the header with the filename
        }
    
       function onSoundLoaded(event:Event):void 
        { 
           var localSound:Sound = event.target as Sound; 
           localSound.play(); 
        }
    

    The solution is not exactly what you want (finding the file name in onSoundLoaded function), but I think it is the best way to go. Hope it helps

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

Sidebar

Related Questions

I am using following code in as3: var Request:URLRequest = new URLRequest(); var xmlMain:XML=new
I have a code as below import flash.media.Sound; import flash.media.SoundChannel; flash.system.Security.allowDomain(*); var request:URLRequest =
Below is my AS3 code: public function load_swfs(event:Event) { var loader:Loader = event.target.getChildAt(0) as
In AS3 i've created a code that load a sound and execute it in
Can someone post an example of as3 code (specifically event listener included) that would
In as3, if I add identical event listeners to an object, for examle txtField.addEventlistener(
In Flex3, I could compile pure as3 code and use embed tags to load
i'm new to flash and want to load an xml file in flash as3
Let's say I have some code like this in AS3 for(...) thing = new
I have a Flash in AS3. I want to dynamically load code that performs

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.