4 Replies Latest reply on Sep 3, 2010 4:00 AM by learn n leverage

    Hi im have a problem in as3 Security sandbox violation please help

    ohasanov

      1 view this tutorial!

      http://www.thetechlabs.com/tutorials/xml/creating-a-weather-widget-with-xml-and-as3/

      2 http://caspianseataxidrivers.centralbaku.com/

      this is my project

      when im test it in flash i have a working flash hi show weather IT WORKS but when i put it on server he give me error

       

       

      Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: http://caspianseataxidrivers.centralbaku.com/cstd.swf cannot load data from http://xoap.weather.com/weather/local/AJXX0001?cc=*&link=xoap&par=1205344398&key=24e1d0074 9192bb2&unit=m.

      at cstd_fla::MainTimeline/frame1()

      i use crossdomain.xml
      <?xml version="1.0" encoding="ISO-8859-1" ?>
      <cross-domain-policy>
      <allow-access-from domain="caspianseataxidrivers.centralbaku.com" />
      <allow-access-from domain="*.centralbaku.com" />
      <allow-access-from domain="xoap.weather.com" />
      <allow-access-from domain="http://xoap.weather.com" />
      </cross-domain-policy>
       
      but he dont WORK ANY IDEAS ????
      Plese help
        • 1. AS3 Code
          ohasanov Level 1

           

          Security.loadPolicyFile("http://www.centralbaku.com/crossdomain.xml");

          var weather_xml_url:String = ("http://xoap.weather.com/weather/local/AJXX0001?cc=*&link=xoap&par=[MYPARTID]&key=[MYPARTKE Y]&unit=m");

           

           

           

           

          var weather:XML = new XML();

          var weather_url:URLRequest = new URLRequest(weather_xml_url);

          var weatherLoader:URLLoader = new URLLoader(weather_url);

           

          weatherLoader.addEventListener(Event.COMPLETE, weatherLoaded);

           

          function weatherLoaded(e:Event):void

          {

          weather = XML(weatherLoader.data);

          temp_txt.text = weather.cc.tmp;

           

          icons_mc.visible = true;

           

          var weather_icon:int = Number(weather.cc.icon.toString())+1;

          icons_mc.gotoAndStop(weather_icon);

           

          //set the complementary text

          var ud:String = weather.head.ud;

          var us:String = weather.head.us;

           

          var city:String = weather.loc.dnam;

          var time:String = weather.loc.tm;

          var temp:String = weather.cc.tmp;

          var flik:String = weather.cc.flik;

          var term:String;

           

           

           

          var wind_v:String = weather.cc.wind.s;

          var wind_gust:String = weather.cc.wind.gust;

          var wind_d:String = weather.cc.wind.d;

          var wind_t:String = weather.cc.wind.t;

           

          var hmid:String = weather.cc.hmid;

          var vis:String = weather.cc.vis;

           

          }

          • 2. Re: AS3 Code
            learn n leverage Level 3

            Hi,

            Looks like you are trying to access data from a remote domain(xoap.weather.com) to a source domain(www.centralbaku.com) where your swf file resides but you have cross domain policy file resides at your source domain instead of having it at your remote domain.

            i.e. When a client hosts content from a particular source domain and that content makes requests directed towards a domain other than its own, the remote domain would need to host a cross-domain policy file that grants access to the source domain, allowing the client to continue with the transaction.

            So this wont work until you get an appropriate cross domain set at your remote domain(xoap.weather.com)

            There are other ways like using proxy script which may work sometime.

             

            Thanks!

             

            PS: pls mark this post as Answered if it helps

            • 3. Re: AS3 Code
              ohasanov Level 1

              yes but i dont now how it may works ??

               

              i try use proxy php he dont work??

               

               

              can you help me to write rights code and cross domain policy plizzz

               

              IM GO CRAZY!!! Plizzzzz Help

              • 4. Re: AS3 Code
                learn n leverage Level 3

                Hi,

                Your policy file looks correct but it has to be placed in weather.com server which requires their permission. Im not aware of the php proxy stuff but was mentioned in the link that you have provided. You may want to follow up with that.

                Thanks!