Load remote swf files in flex
I have a SWFLoader in mxml of my flex app.
<mx:SWFLoader id="swfPreview"
width="10开发者_运维技巧0%" 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
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
精彩评论