Skip to main content
New Participant
December 25, 2008
Question

Loading a compiled Flex swf with the loader class

  • December 25, 2008
  • 4 replies
  • 906 views
I'm not sure whether to post this in a flex forum or here, but since the error is generated from AS3 code, I'll try it here.

When I try to load a compiled flex swf with the loader class I get the following error:
-- Error: Error #2136: The SWF file file:///D|/Documents/.../Test.swf contains invalid data.

As a test I tried 2 very basic programs:
-- See the actionscript code in the attached code...
As you can see I just load the swf without doing anything with it.


Here's the code for the loaded Flex swf:
-- see the flex code in the attached code

I've found very few threads about this error, and even less solutions...Does anyone know if it's even possible to load a Flex swf?
This topic has been closed for replies.

4 replies

New Participant
December 27, 2008
Thanks for trying, now at least I know it's not just me...I'll take it over to the flash developer forum. Although it's probably just some compiler argument. Flashdevelop is just the editor, how can it create different programs with the same compiler?

Well, thanks anyway. Once I discussed this at the flashdevelop forum i'll post a link here for references...
New Participant
December 27, 2008
Hmmm...that's strange. Could it be related to the editor I'm using: FlashDevelop?
Inspiring
December 27, 2008
Tested with FlashDevelop and now I get the same error.
New Participant
December 27, 2008
Hi LuigiL,

The code is attached in my first post of this topic. I've put a test online at http://www.gism.nl/test/test.swf. This is the swf compiled from the as3 code. It's trying to load http://www.gism.nl/test/PhotoViewer.swf. Both files are compiled with the same version of mxmlc.exe. They are now compiled with sdk version 3.1.0 build 2710. But I've also tried other, newer and older, versions.
Inspiring
December 27, 2008
Created the same files myself with the code you attached and it runs fine. Post your sources and enable source view or post your files somewhere.
Inspiring
December 26, 2008
Yes, you can load a swf generated using the Flex Framework (or more specific 'using mxml'). But remember that the 'Flex' swf has two frames. In your loader, wait for the second frame to load (setup a Timer). Using the application property you can communicate with the loaded swf.

var clip:MovieClip = loader.content as MovieClip;
if (clip.currentFrame == 2) {
clip.application.addEventListener("whatever", whateverHandler);
New Participant
December 27, 2008
Hi LuigiL, I'm aware of the 2 frames, but as you can see in my example code, I'm not doing any communication with the Flex app. I'm just loading it, nothing else. I'm guessing the error message would be something like a null pointer error in the case you're describing, but it's totally different.
Inspiring
December 27, 2008
I've never seen the error 'invalid data' before. Upload the code and the swf somewhere.