开发者

Accessing an RSS feed in Flex, works when run from Flash Builder 4, but not when the project is online?

In my Flex 4 app, I access an RSS feed (I'm using http://news.ycombinator.com/rss as a dummy). It works okay when I run it from Flash Builder 4, b开发者_JAVA技巧ut if I export the project and upload it, I get the following error when it tries to load the RSS feed:

Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: my_website_url cannot load data from http://news.ycombinator.com/rss.

What could be causing this error? Shouldn't RSS be able to be accessed from anywhere? Thanks for reading.


Afaik flash looks for a crossdomain.xml (http://news.ycombinator.com/crossdomain.xml) file to detect if it's allowed to download this content. You find a possible solution here.


The Flash Player is in it's own security sandbox inside the browser. It cannot access URLs outside the domain from which it was served unless it is given permission.

That permission is given through the use of a crossdomain.xml file. There is no cross domain file on the ycombinator site, as you can see here: http://news.ycombinator.com/crossdomain.xml . As such flash will not be able to access that URL unless the swf file is also served off ycombinator.

I'm unclear why this works when you test it locally; you should be having the same issue.

If that is your site, you can create a cross domain file and add it to the root directory and your problems should go away. More info here:

http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html

If you need an alternate feed to test with, you can use The Flex Show's RSS:

http://www.theflexshow.com/blog/rss.cfm?mode=full

(our Cross Domain for your reference)

http://www.theflexshow.com/crossdomain.xml


I'm unclear why this works when you test it locally; you should be having the same issue.

This is because when you are running from Flash Builder, the output file is a local file and hence the security domain is different as opposed to a SWF hosted in a web server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜