Unknown IOError When Loading SWF With openfl.display.Loader

Hi everyone,

I am attempting to port an AS3 application and I have hit a dead end. The code requires an external .SWF file to be displayed. Whenever I try to use the Loader class to read it, it returns this generic unidentified error:

[IOErrorEvent type="ioError" bubbles=true cancelable=false text="Unknown error" errorID=0]

Here is a standard 404 error in comparison, if it helps:

[IOErrorEvent type="ioError" bubbles=true cancelable=false text="Cannot load file: fakefile.swf" errorID=0]

Finally, here is my offending code:

public function loadFile(url:String):Void {
  var myRequest:URLRequest = new URLRequest(url);
  var myLoader:Loader = new Loader();

  myLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
  // [unrelated listeners omitted]


public function onIOError(?event:IOErrorEvent):Void {

Is this a limitation of the library or is it able to be fixed or bypassed?

If you are compiling to HTML5 you can often get useful information on IO problems from your browser’s developer tools panel, in particular the console and networking tabs.

1 Like

You could also try switching out the SWF you are using in case it is corrupted somehow.

1 Like

Thanks for your suggestions, I tried them out.

I am compiling to HTML5, so I checked those panels and nothing seems to be out of order. The SWF is loaded with 200 OK.

I created a SWF only consisting of one frame of static text as a placeholder to only receive the same error. I even tried exporting under different Flash Player and Actionscript versions (I am thinking it could be related with AVM1/2).

I have not loaded .swf at runtime myself. I have had success however using the “process” command and then loading assets:
Perhaps that might be an option?

It is my experience that Browsers are blocking files with swf extension. Try renaming the extension to something else and try again. eg yourmovie.swf → yourmovie.fdll

Again this should solve the 404 error, but displaying the swf in your application is even trickier. Depending on the complexity of the SWF, it may be impossible to use at all. SWF containing code will not be able to run at all and SWF assets will require the SWF library to parse the assets. There are a few ways to use SWF assets with your application for different targets although runtime usage with html5 is the trickiest.

In general, this may get you going in the right direction(although it might be a little outdated) : Using SWF Assets (openfl.org)

1 Like

You can’t display the root movieclip.
Create a movieclip in library. And then load it.
I have used SWF several times. Never got any issue or error.

Thanks you all for your replies.

This appeared to be the problem, my intended file was primarily Actionscript and the project I was trying to port acted as just a wrapper for it. I guess I should look into completely refactoring everything, then.

The Ruffle.js library is intended to work the way you describe.

OpenFL was created for ongoing development and improvement of Flash API projects. After the initial port, you can create applications with native integration on mobile, desktop and even console platforms. Ruffle was created to be a Flash emulator, and created recently now that Web Assembly offers a means to parse and run ActionScript in the browser with reasonable performance. Ruffle is intended for places like Newgrounds with a lot of old historical Flash content

Obviously I’d love a solution that does both though that’s the state of the world today :slight_smile: