HttpPost using Flash 8
April 20, 2006 3:40 AM   Subscribe

I wondered if someone could point me in the right direction on a problem I'm having http-posting from Macromedia Flash 8.

I'm trying to get Flash to post a 6000+ character string to a named website. I can't seem to make it work. Firstly, the loadvars function just doesn't seem to do anything. Secondly, I've no idea how to debug it to work out what (if anything) the error is. I suspect the problem is something to do with security rights, but other than that I'm completely stuck.

[Source, Example, Picture of Source Code]

Why won't loadvars work? How do I debug this? What should the ASP be like that reads the information from the Flash?
posted by seanyboy to Computers & Internet (4 answers total)
 
Best answer: I think you need loadVarsVariable.sendAndLoad(...), not loadVarsVariable.send(...). send() just sends data, but doesn't wait for a reply. sendAndLoad waits for a reply and will call your onLoad hander once the load is complete.

Note that you'll need a SECOND loadvars variable to RECEIVE the data coming back from the asp script. You tell sendAndLoad about this variable, and the onLoad handler should run off of THIS variable, not the variable you're using to send data.

send_lv.sendAndLoad(url, result_lv, "POST");
posted by grumblebee at 4:35 AM on April 20, 2006


Is the swf located at the same domain as the website it is accessing?
posted by spaghetti at 7:19 AM on April 20, 2006


Response by poster: spaghetti: Yes it is, but I don't know how the .swf knows what website it is running on. The server has a number of domain names.

So it can be referenced from
http://vsms7.dynamicSelect.co.uk/postfile
or
http://www.myselect.co.uk/postfile

How does Flash know that the site it is posting to is the same as the site the file is held on?

grumblebee: The page doesn't seem to be accessed at all.
Files are automatically created if you access http://www.myselect.co.uk/postfile/post-tair.asp, and these are not being created at all.

http://www.myselect.co.uk/postfile/painter4.html should do the posting to this.

I'm also confused about how the data is posted. As far as I can tell, you can post by passing variables in the URL, or you can post by using "Http-POST" (whatever that is). Documentation seems to imply that loadVars uses the first of these two options, but I can't understand how this would be the case.
posted by seanyboy at 8:47 AM on April 20, 2006


Best answer: OK - I got what I needed. In the end, I used getURL, but I think loadvars should work the same.

This still didn't work, but this was because I needed to create a policy file. This must exist at the root of the domain you wish to post to.

The file looks something like...
<?xml version="1.0"?><!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"><cross-domain-policy>   <allow-access-from domain="www.company.com" /></cross-domain-policy>
More info here
posted by seanyboy at 6:57 AM on April 26, 2006


« Older How do I extract hundreds of attachments?   |   Having trouble with my English lit. Newer »
This thread is closed to new comments.