I would like to load an external image to a flashwebsite. I do this using a Loader.
开发者_开发知识库Here's my code.
private function init():void
{
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
loader.load(new URLRequest(_feed.fromPicture));
}
private function imageLoaded(evt:Event):void
{
var loaderInfo:LoaderInfo = evt.target as LoaderInfo;
dispObj = loaderInfo.content;
this.addChild(dispObj);
}
When I test the swf offline, it works. But when I put everything online and I browse to the HTML file, it doesn't load the images anymore.
What do I have to do to load external images online?
Thanks,
Vincent
I've found the answer. I had to use an proxy to load my images from an other domain. Like this: http://active.tutsplus.com/tutorials/actionscript/quick-tip-using-a-php-proxy-to-load-assets-into-flash/
This code should work both off- and online. If your pictures don't load, there must be some other problem. Perhaps _feed.fromPicture
was not set correctly, or your file paths behave differently. Do you have the Flash content debugger plugin installed? If not, do so. Then set up your flashlog and check the output for error messages.
Is the image you try to load on the same domain as your application? If not, you have to add your domain to the crossdomain.xml file on the server where you try to load the image from.
http://kb2.adobe.com/cps/142/tn_14213.html
Rob
精彩评论