ActionScript 3 Error when dynamically playing audio - actionscript-3

I am writing a game for Air iOS. I have an audio file, saved in the same directory as my .fla file. Here is the code I am using to play it:
import flash.net.URLRequest;
var snd:Sound = new Sound(new URLRequest("507560_-BlastProcess-.mp3"));
snd.play(0, 40);
This is the error I get when testing in thew Air Debug Launcher:
[SWF] Spike%20Jungle.swf - 72668 bytes after decompression
Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.
at SpikeJungle_fla::MainTimeline/frame1()[SpikeJungle_fla.MainTimeline::frame1:128]
at runtime::ContentPlayer/loadInitialContent()
at runtime::ContentPlayer/playRawContent()
at runtime::ContentPlayer/playContent()
at runtime::AppRunner/run()
at ADLAppEntry/run()
at global/runtime::ADLEntry()
[UnloadSWF] Spike%20Jungle.swf
Test Movie terminated.
How do I fix this?

Either need a cross-domain or the path to the file is incorrect.
Your AIR app is probably not running in the same folder as your mp3. See where your compiled air app is being stored and move the mp3 to that folder.
http://www.judahfrangipane.com/blog/2007/02/15/error-2032-stream-error/
You may also want to use a SoundChannel so you can stop the sound

Related

AS3 AIR loading online mp3 - Error #2044: Unhandled IOErrorEvent:

UPDATE: Any version of AIR is blocking any external content. This simple pic script won't work either.
var my_loader:Loader = new Loader();
my_loader.load(new URLRequest("http://edvizenor.com/images/Ed-Vizenor.png"));
addChild(my_loader);
BUT HOW DO I FIX THIS?
UPDATE: More error info:
Attempting to launch and connect to Player using URL C:\Flash Apps 2014\Real Projects\Fr Letherby\Homily.swf
[SWF] C:\Flash Apps 2014\Real Projects\Fr Letherby\Homily.swf - 981 bytes after decompression
*** Security Sandbox Violation ***
Connection to http://traffic.libsyn.com/frleatherby/2015Jul18.mp3 halted - not permitted from file:///C|/Flash%20Apps%202014/Real%20Projects/Fr%20Letherby/Homily.swf
-- Untrusted local SWFs may not contact the Internet.
SecurityError: Error #2028: Local-with-filesystem SWF file file:///C|/Flash%20Apps%202014/Real%20Projects/Fr%20Letherby/Homily.swf cannot access Internet URL http://traffic.libsyn.com/frleatherby/2015Jul18.mp3.
at flash.media::Sound/_load()
at flash.media::Sound/load()
at Homily_fla::MainTimeline/frame1()[Homily_fla.MainTimeline::frame1:2]
Cannot display source code at this location.
BELOW IS THE ORIGINAL POST.
I just got a new comp using windows 8 and installed creative cloud. I am using the Flash IDE and I am trying to load a sound from online. It's a simple script but I am getting this error below.
NOTE: I am using Air 17.0 for Android. It's not working. However, when I load this same script in the flash player it works.
As you can see it's a valid live link: http://traffic.libsyn.com/frleatherby/2015Jul18.mp3
But it won't play. Did abode block this streaming feature? What simple line am I missing. This was so easy before. Is it a setting on my new computer? Thanks for any tips.
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.media.Sound;
import flash.net.URLRequest;
public class Main extends MovieClip {
public function Main() {
// constructor code
var mySound:Sound = new Sound();
mySound.load(new URLRequest("http://traffic.libsyn.com/frleatherby/2015Jul18.mp3"));
mySound.play();
}
}
}
THE ERROR
Error #2044: Unhandled IOErrorEvent:. text=Error #2032: Stream Error.
at Main()[C:\Flash Apps 2014\Real Projects\Fr Letherby\Main.as:13]
at runtime::ContentPlayer/loadInitialContent()
at runtime::ContentPlayer/playRawContent()
at runtime::ContentPlayer/playContent()
at runtime::AppRunner/run()
at ADLAppEntry/run()
at global/runtime::ADLEntry()
[UnloadSWF] Homily.swf
Test Movie terminated.
From your updates, this seems to be a security violation, and you will need to provide AIR the necessary permissions to be able to do this. Try this at the start of your application:
Security.allowDomain("Your Domain URL here");
And, In Flash IDE by going to File->Publish Settings->Flash->Local playback security and choosing either ‘Access local files only’ or ‘Access network only’.
If your application is web-based and is accessing a web-service of some kind on a different domain to the one the .swf file is hosted on you can get a sandbox violation if the domain you are accessing does not have a valid cross domain policy in place. You would also need to place a crossdomain.xml file at the root of your server which you are trying to access. It looks like this:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
<site-control permitted-cross-domain-policies="master-only"/>
</cross-domain-policy>
Hope this helps.

Insert a video on Action Script 3.0

Hi I'm trying to put a FLV video into a flash adobe CC actionscript project and it gives me an error like this one when I try to get to the corresponding photogram:
Error #2044: Unhandled skinError:. text=[SecurityErrorEvent
type="securityError" bubbles=false cancelable=false eventPhase=2
text="Error #2140: Security sandbox violation:
file:///C|/Users/Gael/Desktop/pfc/proxecto.swf cannot load
file:///C|/Users/Gael/Desktop/pfc/SkinOverAllNoVolNoCaptionNoFull.swf.
Local-with-filesystem and local-with-networking SWF files cannot load
each other."]
Can someone tell me how to fix this?
This problem is not caused by flv video. It is caused by the player skin SkinOverAllNoVolNoCaptionNoFull.swf compiled with security sandbox type other than security sandbox type of your application.
You need to change Security sandbox type of your proxecto.swf application.
You can configure a SWF file for the local-with-networking sandbox by setting the document’s publish settings in the authoring tool.

Load local SWF in AIR

I want to be able to load a local SWFs in an AIR desktop application. The SWF files are located outside of the application itself on the user's hard drive.
The code I'm using is as follows:
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
loader.load(new URLRequest("/Users/Oliver/Documents/sample.swf"));
The file does exist. I can test its existence using the following in Unix:
$ ls /Users/Oliver/Documents/sample.swf
However, the application is throwing the error:
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
If I attempt to load the same file from a web location (e.g. http://127.0.0.1/sample.swf), the load succeeds.
I understood that AIR could load both local and remote files. Is this not the case? Ironically, elsewhere in my application I am reading, writing and deleting arbitrary files from the local file system without issue. But I cannot load them?
I believe the issue is with your path. Try using the File class to get a path to your swf.
var f:File = File.documentsDirectory
f = f.resolvePath("sample.swf");
/* ----- */
loader.load(new URLRequest(f.url));

LocalConection between a AIR application and Flash Player application

I'm trying to connect a AS2(swf on Flash player using Flash CS4) and AS3(swf on AIR using Flash Builder 4), but I get an error when I send a command from the AIR app:
[StatusEvent type="status" bubbles=false cancelable=false eventPhase=2 code=null level="error"]
How can I debug this?
Recently I tried LocalConnection between as3 and as2 too with little luck. Then I found SWFBridge classes by Grant Skinner, and they worked for me.

AS3 Crossdomain imageload

Actually i have to load images into stage from any server,
so tried using crossdomain.xml from my server root.
though it throughs error
SecurityError: Error #2122: Security sandbox violation:
Loader.content: http://sss/Player.swf cannot access
http://ffff/images/logo-bg.jpg. A policy file is required, but the
checkPolicyFile flag was not set when this media was loaded. at
flash.display::Loader/get content() at
SS4UPlayer_fla::MainTimeline/ss4uLogoCompleteHandler()
Whats the problem, Please can you find it.
import flash.system.LoaderContext;
Using this LoaderContext i just got clear my problem and loaded config.xml under my root directory.