HTTPRequest and Flash

Monkey Targets Forums/Flash/HTTPRequest and Flash

Xyle(Posted 2015) [#1]
I use HttpRequest to send and receive info from my site and it works great with android, ios, and glfw but I can't get it working with flash and html5

Basically I call getHighScores() when I need to read the score board

	Method getHighScores:Void()
		Print "Getting highscores..."
		Local tURL:String = "http://www.testserver.com"
		
		get_req = New HttpRequest("GET", "" + tURL, Self)
		get_req.Send
	End Method


Calling this method sends a get request and will return information which gets handled by the OnHttpRequestComplete method...
	Method OnHttpRequestComplete:Void(req:HttpRequest)
		Print "Getting httprequest..."
		If req = get_req
			Print "Http GET complete!"
		Else
			Print "Http POST complete!"
		EndIf

		Print "Status=" + req.Status()
		Print "ResponseText=" + req.ResponseText()
	End Method


Typically using these two methods, I get the following printed out...
Getting highscores...
Getting httprequest...
Http Get Complete!
Status=200
ResponseText= whatever is sent from the server goes here

This works fine in everything but html5 and Flash. All I get is the Getting highscores... text printed out.

Before I spend days diving into this, does anyone know if there are settings somewhere that need to be jiggled?

Thanks for any help!


k.o.g.(Posted 2015) [#2]
Do you use UpdateAsyncEvents() in mainloop?
i forgot this many times and asked myself, why it does not work :D


Xyle(Posted 2015) [#3]
Yes, I spent a day wondering why it wasn't working in gflw then found out I didn't have it in.

I got everything working great in all except flash and html5, I am thinking it may be something with the browser or permissions, but I will have to dive in and see what I can find out.

Thanks!


k.o.g.(Posted 2015) [#4]
has the server an origin policy for flash?

http://tiffanybbrown.com/2011/10/10/html5-for-as3-developers-cross-domain-xml-and-cross-origin-resource-sharing/


Xyle(Posted 2015) [#5]
Thanks for the info.

The policy file shouldn't be required if the flash .swf is accessing files in the same domain though right?

I mean it is called a crossdomain policy file, but I'm not crossing domains.

I get the same situation after running the Flash .swf on my server, even after putting the html files in the same directory.


Xyle(Posted 2015) [#6]
Its defnitely a sandbox security issue, using the standalone debugger put out some good info.

If I put the files in the root folder, everything works

If I put the files in a subfolder and copy the highscore files to that folder, it doesn't work. I would think if it accesses files from root without any problem, it would access files in the same subfolder too.

Still pluggin away...


Xyle(Posted 2015) [#7]
Ok, I think the Monkey Gods felt sorry for me, cause I was a crying, hair pulling mess...

As Kog pointed out and finding a post in the forums from slenkar

"paste this into a text file
<?xml version="1.0" ?>
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="*"/>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
save as xml
put the xml file on the root of the remote server
alternatively upload the SWF to the server and run it in a webpage"

Creating the crossdomain.xml file made it all work!

Thanks!


k.o.g.(Posted 2015) [#8]
Its good to hear that ;)