Having trouble with sendAndLoad

  • spiritofcat
  • Born
  • Born
  • spiritofcat
  • Posts: 3

Post 3+ Months Ago

I'm using Flash MX 2004
I'm trying to use sendAndLoad to send data to a python script and then have the python script send some data back, but it just isn't working for me.

The python script runs fine when called directly.
The flash file runs fine if I use load on a static text file of the output from the python script instead of sendAndLoad to call the python script.
They just don't seem to want to talk to eachother.

I've got a Dynamic Text called theDisplay, and a button with this code:
ACTIONSCRIPT Code: [ Select ]
on (release) {
   theDisplay.text = "Please Wait...\n";
   varReceiver = new LoadVars();
   varSender = new LoadVars();
   varSender.theText = "something";
   varSender.sendAndLoad("myScript.py", varReveiver, "GET");
 
   varReceiver.onLoad = function() {
      theDisplay.text += varReceiver.theText;
   };
}
 
  1. on (release) {
  2.    theDisplay.text = "Please Wait...\n";
  3.    varReceiver = new LoadVars();
  4.    varSender = new LoadVars();
  5.    varSender.theText = "something";
  6.    varSender.sendAndLoad("myScript.py", varReveiver, "GET");
  7.  
  8.    varReceiver.onLoad = function() {
  9.       theDisplay.text += varReceiver.theText;
  10.    };
  11. }
  12.  


This is my python script:
PYTHON Code: [ Select ]
#!c:/progra~1/python243/python.exe -u
 
import cgi  # To get the address from the URL.
 
# Print the Content-Type header. Without this it won't work.
print "Content-Type: text/plain\n\n"
 
# Get the text from the URL.
The_Form = cgi.FieldStorage()
myText = The_Form["theText"].value
 
# Write the text to a file.
FILE = open("text.txt","w")
FILE.write(myText)
FILE.write("\n")
FILE.close()
 
# Write the text back in the format that flash wants it in.
print "&theText=" + myText
 
 
  1. #!c:/progra~1/python243/python.exe -u
  2.  
  3. import cgi  # To get the address from the URL.
  4.  
  5. # Print the Content-Type header. Without this it won't work.
  6. print "Content-Type: text/plain\n\n"
  7.  
  8. # Get the text from the URL.
  9. The_Form = cgi.FieldStorage()
  10. myText = The_Form["theText"].value
  11.  
  12. # Write the text to a file.
  13. FILE = open("text.txt","w")
  14. FILE.write(myText)
  15. FILE.write("\n")
  16. FILE.close()
  17.  
  18. # Write the text back in the format that flash wants it in.
  19. print "&theText=" + myText
  20.  
  21.  
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Flanders
  • Beginner
  • Beginner
  • User avatar
  • Posts: 48
  • Loc: Reno, Nevada US

Post 3+ Months Ago

I hope it's not the typo giving you all the trouble with "varReveiver"
  • spiritofcat
  • Born
  • Born
  • spiritofcat
  • Posts: 3

Post 3+ Months Ago

Flanders wrote:
I hope it's not the typo giving you all the trouble with "varReveiver"

*facepalm* Yes, that was it. Thanks.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 10 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.