Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Loading a compiled Flex swf with the loader class

New Here ,
Dec 25, 2008 Dec 25, 2008
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?
TOPICS
ActionScript
999
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 26, 2008 Dec 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);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 26, 2008 Dec 26, 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 27, 2008 Dec 27, 2008
I've never seen the error 'invalid data' before. Upload the code and the swf somewhere.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 27, 2008 Dec 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 27, 2008 Dec 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 27, 2008 Dec 27, 2008
Hmmm...that's strange. Could it be related to the editor I'm using: FlashDevelop?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 27, 2008 Dec 27, 2008
Tested with FlashDevelop and now I get the same error.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 27, 2008 Dec 27, 2008
LATEST
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...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines