views:

102

answers:

1

URLRequest not working in Cross domain in As3?

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
    <mx:Button x="35" y="22" label="Button" click="test()"/>
    <mx:TextArea x="35" y="65" width="365" height="254" id="aaa"/>
    <mx:Script>
     <![CDATA[

      function init():void {
      Security.allowDomain("*");  // localhost, 192.168.0.19
    Security.loadPolicyFile("http://abcomp01.thaifasthost.com/crossdomain.xml"); 
   }

      function test():void {
      var url:String = "http://bbs.pramool.com/webboard/view.php3?katoo=j530492";
            var request:URLRequest = new URLRequest(url);
            var loader : URLLoader = new URLLoader();
            request.url = url;

            request.method = URLRequestMethod.POST;
            loader.addEventListener(Event.COMPLETE, on_complete);
      loader.addEventListener(IOErrorEvent.IO_ERROR, on_error);  
            //navigateToURL(request);
                  try {
                loader.load(request);
            } 
            catch (error:Error) {
            }

      }


      function on_complete(e : Event):void{
      var loader:URLLoader = e.target as URLLoader;
      if (loader != null)
      {
       aaa.text = loader.data;
      }
     }
     function on_error(e : Event):void{
     } 
     ]]>
    </mx:Script>
</mx:Application>

in xml cross domain

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"&gt;
<cross-domain-policy>
    <allow-access-from domain="*" to-ports="*" />
</cross-domain-policy>

how to fix this?

when i upload to my own hoosting but notwork and when in my local it work? :<

A: 

What are you doing with the URLRequest object? One thing to make sure of is that there is a crossdomain.xml policy file on the server you are trying to connect to that server.

Chris Gutierrez
if that domain not have> so i cant used to rip the website?
monkey_boys
yup. It is a security measure to protect the domain you are trying to connect to.
Chris Gutierrez