Security sandbox violation


(Nate ) #1

Hey guys!

So I have my test game, and it allows the user to play, obtain a score, then submit the score to my database. I then can go to the web address and see the score.

For some reason the game does not work when I open it in an internet browser, and it also will not run if I take it out of the bin folder… My question is… how do I get this game to play standalone so I don’t have to send the php files to my friends… I would rather not send them the keys to my server… lol

Any thoughts guys? I already checked my project properties, and use network services is set to true.

Thank you


(David Williams) #2

It should work if you upload it to a server, like dropbox, and then play it through your browser from that link.


(Nate ) #3

I uploaded it to my site and it does not run. The URLRequest which handles moving the score from AS3 to the server side PHP is being pointed to the php file on my server also, it is the entire “http://www.blahblahblah.com/submit.php” Why do you think the stand alone game on my desktop just throws a Security Sandbox Violation? But when I play it from the Bin folder, it runs fine and updates the database like it should.


(David Williams) #4

Local flash files have restrictions on them to prevent malicious code. FlashDevelop’s bin folder is trusted with more security exceptions due to it being an IDE for writing files and what not.


(Nate ) #5

I see, so how would I go about having the stand alone .swf work and not throw a nasty error?


(David Williams) #6

Hmm, what’s triggering the server connection? It might require the use of event listeners for a mouse click or something. Flash Player has a lot of security that can get annoying quickly.


(Nate ) #7

I am using a mouse click on a submit button in the game which then fires a URLRequest which fires a php file which then takes the score and sets it to the value of a php variable which then fires off to my mysql database :smiley:


(David Williams) #8

And that’s about where my help ends. Sorry I can’t figure this out, but I actually had someone else figure this out for me a long time ago and I just copy/paste the code they made.

Maybe another Flashpunk-er will know.


(Nate ) #9

Aw shucks. Well there are BILLIONS of other flash games with leaderboards that run online no problem! There has to be something fundamental that I am missing.

If I just re-create this project as a mobile project with the network access enabled via XML will it just work out of the box then? I think the main issue is Adobe doesn’t want to let my .swf execute because it is accessing the internet…


(Nate ) #10

I got it running on my server, I simply changed the URLRequest from the http://www.blablablabla.com/submit.php – to just submit.php… and now it seems to function.

But I am still wondering how I can make the .swf a standalone and send just the swf to my friend and have him upload his score from the .swf without having to go to the website.


(Jonathan Stoler) #11

This sounds like it’s probably an issue with your project settings, but I’ll share some [modified] code I’ve used successfully in the past (this was wrapped in a class but it should be easy to adapt to whatever you want).

public static function init():void
{
	var request:URLRequest = new URLRequest(_url + "register.php");
	var variables:URLVariables = new URLVariables();
	// variables["key"] = "value" for each of your variables here

	request.data = variables;
	request.method = "POST";


	var loader:URLLoader = new URLLoader();
	loader.addEventListener(Event.COMPLETE, eventComplete);
	loader.addEventListener(IOErrorEvent.IO_ERROR, ioError);
	loader.load(request);
}
private static function ioError(event:Event):void
{
	// provide some sort of error message here
}
private static function eventComplete(event:Event):void
{
	var loader:URLLoader = URLLoader(event.target);
	var data:String = loader.data;
	// data contains the contents of the page after the request
	// (use PHP's echo function to output server-side if you need to)
}

I seem to remember - in one project, but not another - having to move my SWF out of its build folder and onto my Desktop in order for it to work. But I think that might have been with a local file, not a URLRequest, and I could have probably tweaked some setting to fix it, but there was no point. Also this is the opposite of what you described, so…?

You could also try building under a Release configuration rather than a Debug build. Not sure if it’ll help.