The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Cross-site file loading problem (Flash/Actionscript)

JasconiusJasconius sword criminalmad onlineRegistered User regular
edited November 2008 in Help / Advice Forum
I know there aren't many Flash people on this forum but I'm spreading things around hoping to get a solution...

I am having an issue trying to get an XML file loaded. Let me try and paint the picture here of what all is involved.

Myspace.com: Hosting embed code that loads up a SWF from the...

Dev Server: Hosted in the office and housing the SW file. The SWF file then tries to load an XML file from the...

Live Server: A live site that is hosting the XML file. At the moment it is technically the same domain as the dev server... the dev server address is something like (subdomain.url.com) and the live server is just plain vanilla (url.com).

When the code executes on Myspace I get
Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: http://lyrics.url.com/flash/widget.swf cannot load data from http://www.url.com/files/data.xml.
	at PhotoDisplay/Init()
	at WidgetMaker()

Here is the PhotoDisplay class that throws the error (well, only the relevant parts)
package
{
	
	import flash.display.Loader;
	import flash.display.MovieClip;
	
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.MouseEvent;
	
	import flash.external.ExternalInterface;
	
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import flash.text.TextField;
	
	import flash.system.Security;
	
	public class PhotoDisplay extends MovieClip
	{
		
		private var PhotoList:Array = new Array();
		private var URLList:Array = new Array();
		
		private var uloader:URLLoader;
		
		private var xmldata:XML;
		
		public function PhotoDisplay():void
		{			
			Globals.PhotoDisplay = this;			
		}
		
		public function Init():void
		{		
			//Security.allowDomain("http://lyrics.url.com");
			//Security.allowDomain("url.com");
			Security.allowDomain("*");
			
			if(Globals.EditMode)
			{				
				ExternalInterface.addCallback("AddPhoto", AddPhoto);
				ExternalInterface.addCallback("ReorderPhotos", ReorderPhotos);
				ExternalInterface.addCallback("RemovePhoto", RemovePhoto);				
			}
			else
			{
				uloader = new URLLoader();
				uloader.addEventListener(Event.COMPLETE, XMLLoaded);
				uloader.addEventListener(IOErrorEvent.IO_ERROR, XMLError);
				//uloader.load(new URLRequest("/files/widgetimages/" + Globals.Token + "/data.xml"));
				uloader.load(new URLRequest("http://www.url.com/files/data.xml"));
			}			
		}
		
		private function XMLLoaded(e:Event):void
		{			
			xmldata = new XML(uloader.data);
			
			//Globals.Debugger.text = xmldata.toString();
			
			for each(var element:XML in xmldata.images.elements())
			{				
				//Globals.Debugger.appendText(element.toString());
				AddPhoto(element.toString());				
			}
			
		}
		
		private function XMLError(e:IOErrorEvent):void
		{
			//Globals.Debugger.text = "error -- " + Globals.Token;
		}
		
		private function RetrieveImage(theURL:String):Loader
		{
			
			var retval:Loader = new Loader();
			
			if(Globals.EditMode)
			{
				retval.load(new URLRequest("/ImageServe.aspx?t=" + Globals.Token + "&fn=" + theURL));
			}
			else
			{
				retval.load(new URLRequest("/files/widgetimages/" + Globals.Token + "/" + theURL));
			}
			
			return retval;
			
		}

As you can see I've tried few different allowDomain() methods to see if that fixes it, and it doesn't. I've also stuck a crossdomain policy file on the root of the live site and no dice. I cannot figure out what is wrong. Any help?

this is a discord of mostly PA people interested in fighting games: https://discord.gg/DZWa97d5rz

we also talk about other random shit and clown upon each other
Jasconius on

Posts

Sign In or Register to comment.