0

I have a SWFLoader in mxml of my flex app.

<mx:SWFLoader id="swfPreview"
     width="100%" height="90%"  y="20" visible="false"/>

Now on a button click, I execute the following code in action script.

swfPreview.addEventListener(Event.COMPLETE,loadComplete);
swfPreview.scaleContent = true;
swfPreview.load(url);

Where "url" is the url to a swf present on the internet (this domain can be the same or different, I face problems in both cases)

Now, on loadComplete, I do the following:

private function loadComplete(event:Event):void
{
   Alert.show("Load complete");
   swfPreview.removeEventListener(Event.COMPLETE,loadComplete);
   swfPreview.visible = true;
}

I get the alert popup (that is the loadComplete is called) but do not get any swf loaded, not able to view anything. What can be the problem, am I missing something or some security issue? I also tried the image control to load the swf. Moreover, the swf are pdf files converted to swf so can this be an issue of different frame rates between flash and flex ? Any help will be appreciated.

Thanks

Mansuro
  • 4,558
  • 4
  • 36
  • 76
Gaurav
  • 313
  • 1
  • 3
  • 19
  • Have you tried it with a different swf to see if that works as expected? – quoo May 05 '10 at 13:30
  • Actually I tried placing a swf in a domain I have access to and was able to load that swf. I also tried to view the content property of the swf in the other case and I see AVM1movie object in the content. But amazingly while I debugged and left the debugger for some time I saw a message of "securitydomain tried to access incompatible context", I think this is some kind of a security issue, would have to place a crossdomain file. – Gaurav May 06 '10 at 06:30
  • I used a LoaderContext for the SWF loader and uploaded the flex application and then was able to load the swf, hurray!! But my joy was not long lasting I saw the loaded swf was blinking (some of the images in the loaded swf were blinking and no text was visible). Is this related to different frame rates ?? – Gaurav May 06 '10 at 10:31

1 Answers1

0

I never worked with SWFLoader specifically, but it sounds like you are not adding the loaded object to the display. If SWFLoader behaves at least similarly to flash.display.Loader, you will have to get the object on Event.COMPLETE and add it to the display. Something like:

loader = new Loader();
var req:URLRequest = new URLRequest("http://example.com/your.swf");
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
loader.load(req);

private function onComplete(e:Event):void {
    addChild(e.target.loader.content);
}

For an full example using loader, you can check the Vimeo player API, which loads their video player SWF from their site into your app:

http://www.vimeo.com/api/docs/moogaloop

ettore
  • 678
  • 12
  • 20