in AS3 I'm trying to load a URL (a Yahoo address) into the application so I can process the source code and pull things out of it开发者_开发知识库.
However, when I load it, or any other page, I get 0 bytes back.
Here's my current code.
private function doSearch():void {
var req:URLRequest = new URLRequest("http://yahoo.com");
var loader:URLLoader = new URLLoader();
loader.load(req);
loader.addEventListener(Event.COMPLETE, completeHandler);
}
private function completeHandler(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
Alert.show(String(loader.bytesTotal),"HTML", Alert.OK);
}
When this runs, all I receive is a 0 in the alert box, showing me that 0 bytes have been loaded.
Yahoo.com only allows SWF/FlashPlayer access from sub-domains of yahoo.com.
See here http://www.yahoo.com/crossdomain.xml
<!DOCTYPE cross-domain-policy
SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*.yahoo.com" secure="false" />
</cross-domain-policy>
精彩评论