Workaround Solution to Flash Error #2044, Unhandled SecurityError, and Error #2048, Security Sandbox Violation

I sell Flash components on ActiveDen, and while working with a client on my Flash News Ticker we ran into the infamous “Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation” when trying to gather information from an external RSS Feed.

This error occurs when your flash file is trying to get data from a different domain and it can’t because of security reasons on their server. The usual fix for this is to create a crossdomain.xml file that allows access from other websites to use the data on yours, but the problem with that is if you don’t host that site you want the data from then how could you create or update the crossdomain.xml file on their server.

I did find a work around for it though! Not sure if its “the right way to do it” but it does work.

Here is the solution, I copy that url of the feed I want the data from, go to my feedburner account and create a feedburner feed of the same feed. If you don’t know what feedburner is then you should definatly check it out. You basically can sign up for feedburner if you have a google account already. Anyway, after you get the feedburner feed of the data you want you can view it. Then if you want to see the xml version of the Feedburner Feed, you can just add  “?format=xml” onto the end of the url they give you, and this is the normal RSS 2.0 feed that we are wanting.

This is the data you want, because its not on the security problematic website. The next thing I ran into was getting the images to display in the news ticker as well. I kept getting the same error but if I dismissed the errors then they still worked. So I used a try-catch clause to get the error and throw it if it gets one. Here is an example of that code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function imageLoaded(e:Event):void {
	try {
                //make the image into a bitmap and smooth it
		var image:Bitmap = e.target.content as Bitmap;
		image.smoothing = true;
 
		//resizes the image
		e.target.content.width = 55;
		e.target.content.height = 35;
 
	} catch(error:Error) {
		trace("Error catch: " + error);
	}
}

This is called from an event listener when loading it in using a loader object, that looks like this:

imageLoader.contentLoaderInfo.addEventListener(Event.INIT, imageLoaded);

So basically it worked after this, and the images even showed up without showing the error. The only problem is that the images don’t get resized because they can’t be loaded into the swf memory. Here are the examples: the one on the left is the broken example, it can’t get the information it wants to so it just keeps trying to load it. The example on the right shows the fix. (You have to view them in IE so the error warnings appear, another thing to hate about IE. :/ )

Any thoughts or comments are encouraged,
Cya

Tags: , , , , ,

5 Responses to “Workaround Solution to Flash Error #2044, Unhandled SecurityError, and Error #2048, Security Sandbox Violation”

  1. Tyler Young says:

    i always use feedburner to syndicate my blog posts to other subscribers.’*-

  2. Abraham says:

    That solved my problem!! haha!! thanks man, you rock!! :D
    Bye bye #2048

  3. Juan Carlos says:

    thank you sooooo much! Ive been looking for an answer for days!

  4. DTAngram says:

    INCREDIBLE!!! Thank you so much. This works GREAT!!!!

  5. Gear Knobs says:

    i always syndicate feeds on my subcribers and of course feedburner is definitely a great help .-”

Leave a Reply