5 Replies Latest reply on Nov 4, 2009 10:02 AM by TaylorBastien

    crossdomain.xml issue

    aprildavid Level 1

      I am facing a problem. I am working on socket. If I run my application from eclipse's flex plugin, it works fine.

      But I load the swf to server, I got "on ErrorError #2048: Security sandbox violation: https://10.3.54.30:4343/HttpStreaming.swf cannot load data from 10.3.54.30:4343.".

       

      I have put the crossdomain.xml under directory to allow any access and any port.We can't open another port 843 as recommonded by adobe. So I directly called Security.loadPolicyFile("http://10.3.54.30/images/crossdomain.xml");

       

      MY code is below. Can you tell me how to fix the problem? A lot of thanks!

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:cmp="org.httpclient.*" borderStyle="none" height="500" width="500" creationComplete="initInterface()">
      <mx:Script>
      <![CDATA[
          import com.adobe.net.URI;
          import org.httpclient.events.*;
          import mx.controls.TextArea;
          import mx.containers.Panel;
           import mx.controls.Alert;
          import asscript.*;
          
           import mx.controls.Alert;
          import org.httpclient.*;
         
          var output:TextArea;
          var bufferSize:int=1024;
          var dataIn:Array=new Array();
          var rDataSize:int=0;
          var count:int=0;
          var inputByteArray:ByteArray=new ByteArray();
         
          var dataString:String=new String();
          var s1:Number;
          var s2:Number;
         
           public function initInterface():void 
           {
               Security.loadPolicyFile("http://10.3.54.30/images/crossdomain.xml");
               output=new TextArea();
               output.width=500;
               output.height=500;
          
              this.addChild(output);
             
              /* var myTimer:Timer = new Timer(100, 20000);
              myTimer.addEventListener("timer", updateUI);
              myTimer.start(); */

       

             
              var client:HttpClient = new HttpClient();
                 
          /*    client.listener.onStatus = function(event:HTTPStatusEvent):void
              {
                   Alert.show("on status");
              };*/
         
          client.listener.onData = function(event:HttpDataEvent):void
          {
                var d:ByteArray = event.bytes;
               
                inputByteArray.writeBytes(d);
                count=count+d.length;
               
            //    if(inputByteArray.length>=bufferSize)
                {
                    updateUI1();
                }
               
                /*var d:String= event.readUTFBytes();
                rDataSize=rDataSize+d.length;
                count=count+d.length;
                if(rDataSize>bufferSize)
                {   
                    rDataSize=0;
                    updateUI1();
               
                }*/
          };

       

          client.listener.onComplete = function(event:HttpResponseEvent):void {
              var now2:Date=new Date();
              s2=now2.getTime()-s1;
               Alert.show("on Complete"+count +"time "+s2+ "array="+inputByteArray.length);
               updateUI2();
          };

       

          client.listener.onError = function(event:ErrorEvent):void {
            var errorMessage:String = event.text;
            Alert.show("on Error"+errorMessage);
          };     

       

          var uri:URI = new URI("http://10.3.54.30/images/spectrumdata");
          var now:Date = new Date();
          s1=now.getTime();
          client.get(uri);       
            }
         
          public function updateUI(event:TimerEvent):void
          {
              output.text+=".";
          }
          public function updateUI2():void
          {   
          /*    var iByteArray:ByteArray=new ByteArray();
              iByteArray.writeDouble(Math.PI);
              iByteArray.position=0;
              var k:Number=iByteArray.readDouble();
               output.text+=" "+k;*/       
              inputByteArray.position=0;           
             do
             {
              var i:uint=inputByteArray.readByte();
              output.text+=i+" ";   
             }
            while(inputByteArray.bytesAvailable!=0);
          } 
          public function updateUI1():void
          {
              // var bArray:ByteArray=new ByteArray();
              /*if(inputByteArray.length>1024)
                  inputByteArray.readBytes(bArray,0,1024);*/
              output.text+=".";
          } 
           
      ]]>
      </mx:Script>   

       

      </mx:Application>