0

Looking for some help catching flash as3 POST command with python.
Anyone done this? below is my AS3 Code:(I have on pretty good authority that this part is right)

function savedata(event:MouseEvent):void { 
	 trace ("i've been clicked");
	 var myData:URLRequest = new URLRequest("user_info.py")
         myData.method = URLRequestMethod.POST
         var variables:URLVariables = new URLVariables()
         variables.fullname = fullname.text
         myData.data = variables
}

it points to the user_info.py which reads:

#this 'import' part is a guess
import POST

# Retrieve  shared variables
mallvars = POST()

#Read a shared variable
fullname = mallvars.fullname

# Write a shared variable
import datetime
import time

#set the text file name
from time import strftime
the_time = strftime("%Y-%m-%d_%H.%M.%S")
myFile = "gal-01_"
myFile += str(the_time)
myFile += ".csv"

#Convert all captured variables to strings
w1 = str(fullname)

# Write Variables to file in CSV format
text_file = open('C:\%s' % myFile, "w")

text_file.write("Name, ")
text_file.write(w1)
text_file.write(" \n")


text_file.close()

Any help with an approach to this is appreciated.

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by perica.zivkovic
0

thanks for the reply. That looks like it's for a web service, this is for a standalone application that will go on a touch screen kiosk. I don't think setting up a web server on each machine would be a good idea. I'm so shocked that over the last 10+ years I've been working with flash that they haven't bothered to write this ability into the program.

0

Well you can put webserver on one central place and then call it from every kiosk and save data to it (or database).

On the other hand I was executing external apps from as3 something like this

import flash.net.navigateToURL;
import flash.net.URLRequest;


myButton.addEventListener(MouseEvent.CLICK, runApp);

function runApp(event:MouseEvent):void {
  var url:String = "MyApp.exe";
  var request:URLRequest = new URLRequest(url);
  navigateToURL(request);
}

and that was working good. So I'm guessing that if you replace "MyApp.exe" with "python_script.py parameter1 parameter2" you can use sys.argv (http://www.faqs.org/docs/diveintopython/kgp_commandline.html) to get your parameters in the python script.

Hope this helps, my as3 knowledge is not greatest :-)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.