0

I'm building an AS3 project in FlashDevelop where I use a URLRequest to load external .pngs from an assets folder in the bin/ directory. It works great when run from FlashDevelop or when run from the bin/ folder (which makes sense since as I understand FD sets bin/ to be a trusted directory) but doesn't work when the bin/ folder is moved or renamed.

I've seen people say that if the compiler option Use Network Services is set to false it should be able to load from a local file system but this isn't working for me and I haven't heard of anyone having success with it.

Am I missing something? If this is impossible is there another way to load .pngs from a local file system?

EDIT: The code I'm using to load the .pngs is

var url:URLRequest = new URLRequest("assets/sprite1.png");
var l:Loader = new Loader();
l.load(url);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadCallBack);

Later in the code I have

private function onLoadCallBack(e:Event):void
{
    var bmp:Bitmap = e.target.content;
    //do things with bmp
    addChild(bmp);
}
Mike Ball
  • 68
  • 7
  • "Doesn't work"? Please try and describe what happens, doesn't happen, etc. Also how are you testing it, using the standalone player, debug player, browser? – puggsoy May 28 '13 at 01:30
  • Sorry, by "doesn't work" I mean the content is never loaded, the callback for Event.COMPLETE never runs. I'm testing it using the standalone Adobe Flash Player 11.7 r700. – Mike Ball May 28 '13 at 01:37
  • Well if you could add some code to your question that would help, specifically the bit loading the .pngs. – puggsoy May 28 '13 at 01:40
  • Add a `IOErrorEvent.IO_ERROR` and `SecurityErrorEvent.SECURITY_ERROR` listener and not just the `Event.COMPLETE`. That way you can at least see if it fails to load because the file cannot be found, or if it fails because of security sandbox issues. – Strille May 28 '13 at 09:07
  • @Strille, thanks for the suggestion, it got a security error. After a bit more research around that I found an answer, posted below. – Mike Ball May 28 '13 at 12:11

1 Answers1

0

I managed to get it to work. For whatever reason just setting Use Network Services to false in the compile options wasn't doing anything so I added -use-network=false to my compiler flags and my assets now load correctly.

Mike Ball
  • 68
  • 7